fix: normalize OpenAI custom URLs to prevent /v1 duplication #8283
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.
Description
This PR fixes an issue where custom OpenAI-compatible API URLs that already end with
/v1were getting another/v1appended, resulting in/v1/v1which caused API requests to fail.Problem
When users configure a custom OpenAI-compatible API URL that already includes
/v1(e.g.,https://custom.api.com/v1), the system was appending another/v1, creating invalid URLs likehttps://custom.api.com/v1/v1/chat/completions.Solution
Added a
normalizeBaseUrl()method to the OpenAiHandler class that:/v1is present for OpenAI-compatible APIs/v1is already presentApplied the same normalization logic to the
getOpenAiModels()functionTesting
/v1/v1Related Issue
Fixes #8282
Checklist
Important
Fixes URL normalization in
OpenAiHandlerandgetOpenAiModels()to prevent/v1duplication for OpenAI-compatible APIs, with tests added.normalizeBaseUrl()toOpenAiHandlerto ensure/v1is present for OpenAI-compatible APIs without duplication.getOpenAiModels()to apply the same URL normalization logic.openai.spec.tscovering various URL formats, including those with trailing slashes and Azure endpoints./v1are not modified./v1have it added correctly.This description was created by
for b736800. You can customize this summary. It will automatically update as commits are pushed.