Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 7, 2026

Related GitHub Issue

Closes: #10337

Description

This PR attempts to address Issue #10337 by implementing the suggestion from @politsin to support both URL formats for custom OpenAI base URLs.

The Problem:
When using the "Use a custom base URL" checkbox, users were confused about whether to include /v1 in their base URL. Some OpenAI-compatible APIs expect the URL without /v1 (they append it themselves), while others expect the full URL including /v1.

The Solution:

  1. URL Normalization Utility: Added normalizeOpenAiBaseUrl() function that handles both formats:

    • https://my-host.example -> https://my-host.example
    • https://my-host.example/v1 -> https://my-host.example
    • Strips trailing slashes and /v1 suffix to normalize the URL
  2. Backend Integration: Updated openai-native.ts to use the normalization function in both:

    • OpenAI SDK client initialization
    • Manual SSE fallback request URL construction
  3. UI Guidance: Added a hint text below the custom base URL field explaining that both formats are supported.

Test Procedure

  1. Unit Tests: Run cd src && npx vitest run utils/__tests__/normalizeOpenAiBaseUrl.spec.ts

    • 25 tests covering various URL formats and edge cases
  2. Manual Testing:

    • Enable "Use custom base URL" checkbox for OpenAI provider
    • Enter URL without /v1: https://api.openai.com
    • Enter URL with /v1: https://api.openai.com/v1
    • Both should work correctly without double /v1/v1 in the request path

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome!


Important

Introduces normalizeOpenAiBaseUrl() to standardize OpenAI base URLs, updating backend and UI components, with comprehensive tests.

  • Behavior:
    • Added normalizeOpenAiBaseUrl() function in normalizeOpenAiBaseUrl.ts to normalize OpenAI base URLs by removing /v1 suffix and trailing slashes.
    • Updated openai-native.ts to use normalizeOpenAiBaseUrl() for SDK client initialization and SSE fallback request URL.
    • Added UI hint in OpenAI.tsx to inform users that both URL formats are supported.
  • Testing:
    • Added unit tests in normalizeOpenAiBaseUrl.spec.ts to cover various URL formats and edge cases.

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

Fixes #10337

- Add normalizeOpenAiBaseUrl utility to handle both URL formats
  (with and without /v1 suffix)
- Update openai-native.ts to use the URL normalization function
- Add UI guidance text explaining supported URL formats
- Add translation string for the base URL hint
- Add comprehensive tests for URL normalization
@roomote
Copy link
Contributor Author

roomote bot commented Jan 7, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly normalizes OpenAI base URLs to support both formats (with and without /v1 suffix). The utility function is well-tested with 25 comprehensive test cases covering various edge cases.

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 Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Openai - The language model did not provide any assistant messages

3 participants