fix: use LM Studio native API endpoint (/api/v1) instead of OpenAI-compatible (/v1)#12224
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: use LM Studio native API endpoint (/api/v1) instead of OpenAI-compatible (/v1)#12224roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #12223
Description
This PR attempts to address Issue #12223. The LM Studio provider was hardcoding the OpenAI-compatible
/v1path for all API requests, even though the user selected "LM Studio" as the provider. This meant requests went to/v1/chat/completionsand/v1/modelsinstead of the native LM Studio endpoints at/api/v1/chat/completionsand/api/v1/models.The native
/api/v1endpoint (introduced in LM Studio 0.4.0) provides features like stateful chats, prompt caching, and context length management that are not available through the OpenAI-compatible endpoint.Changes made:
src/api/providers/lm-studio.ts: Changed OpenAI clientbaseURLfrom/v1to/api/v1, and model listing endpoint from/v1/modelsto/api/v1/modelssrc/api/providers/fetchers/lmstudio.ts: Changed connection test and model fetching endpoints from/v1/modelsto/api/v1/models/api/v1pathsFeedback and guidance are welcome.
Test Procedure
cd src && npx vitest run api/providers/__tests__/lmstudio.spec.ts api/providers/__tests__/lm-studio-timeout.spec.ts api/providers/fetchers/__tests__/lmstudio.test.ts/api/v1/*endpoints instead of/v1/*Pre-Submission Checklist
Documentation Updates
Additional Notes
The native LM Studio API at
/api/v1uses the same response format as the OpenAI-compatible endpoint, so the OpenAI SDK client continues to work without any parsing changes. The key benefit is that the native endpoint enables LM Studio-specific features like stateful chats and prompt caching.Interactively review PR in Roo Code Cloud