Change base_url without building the wrong request URL
How to set an API base URL so the path is right: origin vs versioned base vs full endpoint, why /v1 doubles, and how to check what your client sends.
To change an API base URL without breaking the request, separate the service base from the resource path and then check the URL the client actually sends. UplinkSwitch's base is https://api.uplinkswitch.com/v1, and the rule is simple: /v1 must appear exactly once in the path the gateway routes, and a client that sends it twice is relying on the fold explained below. Most base-URL problems are one of two mistakes, pasting a whole endpoint into a field that wanted a base, or not noticing that a client adds its own version segment. This page is language-neutral; the constructor options for each SDK are on the pages linked at the end.
Three things that are not the same
- The origin is the host only:
https://api.uplinkswitch.com. Nothing routes here on its own. - The versioned API base is the origin plus the version:
https://api.uplinkswitch.com/v1. This is the value a base-URL field wants on an OpenAI-style client; the Anthropic-style case is below. - The full endpoint is the base plus the resource:
https://api.uplinkswitch.com/v1/chat/completions. This is where a request lands; it is not a base.
The intended final paths are /v1/chat/completions for OpenAI-format chat, /v1/messages for the Anthropic Messages format, and /v1/responses where a client uses it. In every case /v1 shows up once.
Why the version segment doubles
Clients fall into two camps, and the camp decides what you put in the base field.
- Clients that append the resource only. An OpenAI-style client whose base already ends in
/v1adds just/chat/completions, giving/v1/chat/completions. Here the base ishttps://api.uplinkswitch.com/v1, and pasting the full endpoint into that field is what produces a mangled path. - Clients that append a versioned resource. An Anthropic-style client adds
/v1/messagesitself. If its base is also set to end in/v1, the path becomes/v1/v1/messages. The gateway folds that doubled segment back to/v1/messages, so the canonical base is still safe to use, but it is worth knowing why the doubled form appears. That fold was checked on the live service on 2026-11-22: a request sent to/v1/v1/messagesreached the Messages route, while an unknown segment such as/v1/v2/messagescame back 404route_not_found.
So the fix for a duplicated version is not to strip /v1 blindly; it is to know which camp your client is in and set the base to match, then confirm the result.
Check the URL, not the field label
Never trust the field name to tell you the final path. Confirm it from the client itself: enable the client's request logging, or point it at a local inspection endpoint that echoes the path, and read the line that shows the method and path. Redact the authorization header before you log anything, so the check never writes a credential to a file. A single captured request showing POST /v1/chat/completions or POST /v1/messages is worth more than any amount of reasoning about the field.
When an application builds more than one client, decide precedence deliberately: an explicit base passed in code and a base from an environment value can disagree, and which one wins is a property of the client. The per-language pages, the OpenAI Python guide, the OpenAI Node guide and the Anthropic Python guide, give the exact options and precedence; the SDKs guide gives the generic setup; and the business case for switching is on the OpenAI API alternative page. This page owns only how the URL is composed.