fix(cli): remove /api/v1 from custom endpoint base URL hint#1575
fix(cli): remove /api/v1 from custom endpoint base URL hint#1575
Conversation
The onboard wizard's "Other OpenAI-compatible endpoint" prompt showed `https://openrouter.ai/api/v1` as the example base URL. The SDK appends `/api/v1` internally, so users who followed the hint got a doubled path and a misleading 429 error. Drop the path suffix from the example so users enter just the hostname. Closes #1171 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
📝 WalkthroughWalkthroughThe onboarding wizard's example text for OpenAI-compatible base URLs was corrected. The prompt example changed from Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@bin/lib/onboard.js`:
- Line 2375: The prompt currently shows "https://openrouter.ai" which lacks the
required /api/v1 path; update the prompt call (the prompt(" OpenAI-compatible
base URL ...") invocation) to show the full example
"https://openrouter.ai/api/v1" and/or add normalization after reading the user's
input (the variable that captures the prompt result) to parse the URL and
automatically append "/api/v1" when the supplied value has no path (and ensure
you don't append if a path already exists or if the input already ends with
"/api/v1" to avoid double slashes); use standard URL parsing to detect host-only
vs path-present and trim trailing slashes when constructing the final base URL
used for probes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 03142c7b-9997-4726-90e2-85b3dc30cc3d
📒 Files selected for processing (1)
bin/lib/onboard.js
| const endpointInput = isNonInteractive() | ||
| ? (process.env.NEMOCLAW_ENDPOINT_URL || "").trim() | ||
| : await prompt(" OpenAI-compatible base URL (e.g., https://openrouter.ai/api/v1): "); | ||
| : await prompt(" OpenAI-compatible base URL (e.g., https://openrouter.ai): "); |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
For OpenRouter's OpenAI-compatible API, what exact base URL should clients use for Responses/Chat Completions requests? Is it https://openrouter.ai` or https://openrouter.ai/api/v1?`
💡 Result:
Use https://openrouter.ai/api/v1 as the OpenAI-compatible base URL (not just https://openrouter.ai). (openrouter.ai)
Then send requests to the usual paths, e.g.:
- Chat Completions:
POST https://openrouter.ai/api/v1/chat/completions(openrouter.ai) - Responses:
POST https://openrouter.ai/api/v1/responses(openrouter.ai)
Citations:
- 1: https://openrouter.ai/docs/api-reference/chat-completion?utm_source=openai
- 2: https://openrouter.ai/docs/api-reference/chat-completion?utm_source=openai
- 3: https://openrouter.ai/docs/api/reference/responses/basic-usage?utm_source=openai
🌐 Web query:
In the OpenAI Node SDK, does setting baseURL to a host-only URL auto-append /api/v1, or must the full API base path be provided explicitly?
💡 Result:
No—baseURL is used as-is. The OpenAI Node SDK does not auto-append /api/v1 (or any version path) when you provide a host-only URL; you must include the full base path yourself (e.g., https://your-host/api/v1 or https://your-host/v1, depending on your server). The SDK’s URL builder simply concatenates baseURL with the request path (handling only the slash boundary). [1]
By default, the SDK’s baseURL is explicitly set to https://api.openai.com/v1, which further implies the version path is part of the base URL, not something appended automatically. [2]
Answer: You must provide the full API base path explicitly; host-only baseURL will not have /api/v1 appended. [1][2]
References: [1] https://app.unpkg.com/openai%406.21.0/files/client.mjs, [2] https://github.com/openai/openai-node/blob/08833f20ae4eab6d23ddf989557e1c05a471352b/src/index.ts
Update prompt example to include /api/v1 base path or add automatic path handling
The example at line 2375 shows https://openrouter.ai, but OpenRouter's OpenAI-compatible API requires https://openrouter.ai/api/v1 as the base URL. The OpenAI Node SDK does not auto-append /api/v1—it uses the baseURL parameter as-is. This means validation probes will incorrectly target https://openrouter.ai/chat/completions instead of https://openrouter.ai/api/v1/chat/completions and will fail.
Either (a) update the prompt to show the full base path (https://openrouter.ai/api/v1), or (b) add logic to automatically append /api/v1 when the user provides a host-only URL for OpenAI-compatible endpoints.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@bin/lib/onboard.js` at line 2375, The prompt currently shows
"https://openrouter.ai" which lacks the required /api/v1 path; update the prompt
call (the prompt(" OpenAI-compatible base URL ...") invocation) to show the
full example "https://openrouter.ai/api/v1" and/or add normalization after
reading the user's input (the variable that captures the prompt result) to parse
the URL and automatically append "/api/v1" when the supplied value has no path
(and ensure you don't append if a path already exists or if the input already
ends with "/api/v1" to avoid double slashes); use standard URL parsing to detect
host-only vs path-present and trim trailing slashes when constructing the final
base URL used for probes.
Summary
Fixes #1171
Problem: The onboard wizard's "Other OpenAI-compatible endpoint" prompt shows
https://openrouter.ai/api/v1as the example base URL. The OpenAI SDK appends/api/v1internally, so users who follow the hint get a doubled path (/api/v1/api/v1), causing a 429 error. The error message then tells the user to try a different model name, which is misleading since the URL is the actual problem.Fix: Drop the
/api/v1suffix from the example so users enter just the hostname (e.g.,https://openrouter.ai).Summary by CodeRabbit