feat: add /v1/models fallback for LiteLLM when /v1/model/info is inaccessible#11899
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
feat: add /v1/models fallback for LiteLLM when /v1/model/info is inaccessible#11899roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
… LiteLLM When /v1/model/info returns a non-200 status (e.g. 403 Forbidden), the function now automatically falls back to /v1/models to retrieve the model list. This helps enterprise/managed LiteLLM users where /v1/model/info may be blocked by API gateways or internal policies. Closes #11898
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: #11898
Description
This PR attempts to address Issue #11898. Feedback and guidance are welcome.
When
/v1/model/infois inaccessible (e.g. 403 Forbidden due to API gateways or internal policies), thegetLiteLLMModelsfunction now automatically falls back to/v1/models(the OpenAI-compatible endpoint) to retrieve the model list.Key implementation details:
buildHeaders,buildUrl)parseModelInfoResponse(for/v1/model/info) andparseModelsListResponse(for/v1/models)getLiteLLMModelsfunction now tries/v1/model/infofirst. If it fails for any reason (HTTP error, network error, unexpected format), it catches the error, logs it, and retries with/v1/models/v1/modelsfallback uses sensible defaults (8192 max tokens, 200k context window) since that endpoint provides less metadata/v1/model/infoworks will see no behavior changeTest Procedure
cd src && npx vitest run api/providers/fetchers/__tests__/litellm.spec.ts/v1/modelswhen/v1/model/inforeturns 403/v1/modelswhen/v1/model/inforeturns 500/v1/modelswhen/v1/model/inforeturns unexpected formatparseModelInfoResponseandparseModelsListResponseparsersPre-Submission Checklist
Documentation Updates
Additional Notes
This change helps enterprise/managed LiteLLM users where
/v1/model/infomay be blocked by API gateways, VPNs, or internal policies, while/v1/modelsremains accessible.Interactively review PR in Roo Code Cloud