litellm - ✅(Solved) Fix Wrong uri construction causes multiply /v1 in the api requesr [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26009Fetched 2026-04-19 15:06:20
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1labeled ×1

Fix Action

Fixed

PR fix notes

PR #26037: fix: url construction for trailing v1 base urls

Description (problem / solution / changelog)

Relevant issues

<!-- e.g. "Fixes #000" -->

Fixes #26009

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Screenshots / Proof of Fix

<!-- Include screenshots, screen recordings, or log output demonstrating that your changes work as expected. For bug fixes: show reproduction before the fix and passing behavior after. For new features: show the feature working end-to-end. For UI changes: include before/after screenshots. -->

Before fix: test failing

PASS: https://api.openai.com                    -> https://api.openai.com/v1/models
PASS: https://api.openai.com/v1                 -> https://api.openai.com/v1/models
FAIL: https://opencode.ai/zen/v1                -> https://opencode.ai/v1/models
      expected                                   -> https://opencode.ai/zen/v1/models
FAIL: https://opencode.ai/zen                   -> https://opencode.ai/v1/models
      expected                                   -> https://opencode.ai/zen/v1/models
PASS: http://localhost:11434/v1                 -> http://localhost:11434/v1/models

After fix: tests passing

tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_plain_base_url PASSED [ 11%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_trailing_slash PASSED [ 22%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_v1_already_present PASSED [ 33%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_v1_with_trailing_slash PASSED [ 44%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_subpath_with_v1 PASSED [ 55%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_subpath_with_v1_trailing_slash PASSED [ 66%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_subpath_without_v1 PASSED [ 77%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_localhost_with_port_and_v1 PASSED [ 88%]
tests/litellm/llms/test_openai_get_models_url.py::TestGetModelsUrl::test_localhost_without_v1 PASSED [100%]

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🐛 Bug Fix

Changes

Fix: Preserves sub-paths in api_base and avoids duplicate /v1 segments when calling get_models() in OpenAIGPTConfig. Fixes #26009. Tests: Adds unit tests for get_models() URL construction across multiple api_base formats.

Changed files

  • litellm/llms/openai/chat/gpt_transformation.py (modified, +9/-6)
  • tests/litellm/llms/test_openai_get_models_url.py (added, +87/-0)
RAW_BUFFERClick to expand / collapse

https://github.com/BerriAI/litellm/blob/0b50a29bafff7b3abfa8d663f13942d7ee2cefc1/litellm/llms/openai/chat/gpt_transformation.py#L731

<img width="1080" height="240" alt="Image" src="https://github.com/user-attachments/assets/877cb990-278f-46ec-9f19-8192d708e92f" /> (requesting opencode zen via litellm proxy with api base=https://opencode.ai/zen/v1)

extent analysis

TL;DR

The issue may be related to the gpt_transformation.py file, specifically around line 731, and could be resolved by investigating the API request to https://opencode.ai/zen/v1 via the Litellm proxy.

Guidance

  • Investigate the API request being made to https://opencode.ai/zen/v1 to ensure it is correctly formatted and authorized.
  • Check the Litellm proxy configuration to ensure it is correctly forwarding requests to the OpenCode API.
  • Verify that the OpenCode API is available and responding correctly to requests.
  • Review the code around line 731 in gpt_transformation.py to ensure it is handling API responses correctly.

Notes

The provided image does not contain any visible text or information that can be used to diagnose the issue, so it is unclear what specific error or behavior is being experienced.

Recommendation

Apply workaround: Investigate and verify the API request and proxy configuration to identify the root cause of the issue, as there is not enough information to suggest a specific fix or upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING