Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Nov 20, 2025

This PR attempts to address Issue #9426. Feedback and guidance are welcome.

Problem

Users were encountering errors when using custom OpenAI-compatible base URLs:

  • URLs with /v1 suffix would error
  • URLs without /v1 suffix would also error
  • The OpenAI provider was not properly handling custom base URLs

Solution

  • Added a normalizeOpenAiBaseUrl helper function to intelligently handle URL normalization
  • Automatically appends /v1 suffix to OpenAI-compatible URLs when missing
  • Properly detects and skips normalization for Azure endpoints which use different path structures
  • Applied normalization to both OpenAiHandler constructor and getOpenAiModels function

Changes

  • Modified src/api/providers/openai.ts to add URL normalization logic
  • Added comprehensive test coverage in src/api/providers/__tests__/openai.spec.ts

Testing

  • Added unit tests for various URL formats (with/without /v1, trailing slashes, Azure endpoints)
  • All existing tests pass without regression
  • New tests verify proper URL normalization behavior

Fixes #9426


Important

Adds URL normalization for OpenAI-compatible base URLs, ensuring consistent handling with or without '/v1' suffix, excluding Azure endpoints.

  • Behavior:
    • Adds normalizeOpenAiBaseUrl function to handle URL normalization in openai.ts.
    • Automatically appends /v1 to OpenAI-compatible URLs if missing, except for Azure endpoints.
    • Applies normalization in OpenAiHandler constructor and getOpenAiModels function.
  • Testing:
    • Adds unit tests in openai.spec.ts for URL formats with/without /v1, trailing slashes, and Azure endpoints.
    • Ensures all existing tests pass without regression.
  • Misc:
    • Updates openai.ts to use normalizeOpenAiBaseUrl in URL handling logic.

This description was created by Ellipsis for 4cb6444. You can customize this summary. It will automatically update as commits are pushed.

- Add normalizeOpenAiBaseUrl helper function to handle URL normalization
- Automatically append /v1 to custom OpenAI-compatible base URLs when missing
- Skip /v1 suffix for Azure endpoints which have different path structures
- Update both OpenAiHandler constructor and getOpenAiModels function
- Add comprehensive tests for URL normalization scenarios

Fixes #9426
@roomote roomote bot requested review from cte, jr and mrubens as code owners November 20, 2025 08:32
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug Something isn't working labels Nov 20, 2025
@roomote
Copy link
Contributor Author

roomote bot commented Nov 20, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. The implementation successfully addresses the custom OpenAI base URL issue with proper URL normalization, comprehensive test coverage, and correct handling of Azure endpoints. No issues found.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Nov 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:L This PR changes 100-499 lines, ignoring generated files.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] openai provider use custom base URL error

3 participants