What Is a Base URL? How API Endpoints Are Built and the /v1 Trap
A base URL is the "first half" of the request address you use when calling an AI API. It is also called the API address or base address. You enter it in your tool, and the tool appends the path for each specific feature to build the full request URL. Change the base URL and the same tool sends its requests to a different service. That is why switching providers can be as simple as changing one address.
If you are new to APIs, read What is an AI API: a one-page explainer for beginners first, then come back to this article.
Are base URL and endpoint the same thing?
Not quite. People often use the two terms interchangeably, but strictly speaking they differ:
- Base URL: the first half, made up of the protocol, the domain, and possibly a version number, for example
https://example.com/v1. - Endpoint: the full address of one specific feature, for example
https://example.com/v1/chat/completions. - Path: the part of the endpoint after the base URL, for example
/chat/completions.
The relationship is: endpoint = base URL + path. The tool or SDK fills in the path based on the feature you call, so you usually only need to enter the base URL.
How is a full request URL put together?
Take the OpenAI-compatible format as an example:
https://api.openai.com/v1/chat/completions
└──── 协议+域名 ────┘└版本┘└──── 路径 ────┘
└──────── base url ───────┘
(The labels in the diagram read: protocol + domain, version, path, and base url.)
The OpenAI SDK's default base URL is https://api.openai.com/v1. It already includes /v1, and paths such as /chat/completions are appended after it.
Anthropic does it slightly differently. The official SDK's base URL is https://api.anthropic.com, without /v1, and the SDK adds /v1/messages itself.
This is where beginners trip most often: different tools follow different conventions on whether the base URL should include /v1. Check the official documentation of the tool and service you are using.
What happens if you add or leave out /v1?
Start with one rule of thumb: look at the full request URL in the error message and check whether it contains /v1/v1 or is missing /v1.
| What you entered | Path the tool appends | Actual request | Typical symptom |
|---|---|---|---|
https://x.com/v1 (tool expects /v1 included) | /chat/completions | .../v1/chat/completions | Works |
https://x.com (tool expects /v1 included) | /chat/completions | .../chat/completions | Usually 404 |
https://x.com/v1 (tool expects /v1 not included) | /v1/messages | .../v1/v1/messages | Usually 404 |
https://x.com/v1/ (extra trailing slash) | Depends on the tool | May produce a double slash | Some tools return 404 |
| The full endpoint | Path appended again | Duplicated path | 404 or a parsing error |
A 404 generally means "there is no such path at this address," not that your key is wrong. A 401 is the code that more often points to an invalid or missing key. For more detailed troubleshooting, see Cline OpenAI Compatible returns 401 or 404: how to fill in the Base URL. If you use Cursor, see Cursor custom API settings: where the Base URL applies and what to check when it has no effect.
How do you check that your base URL is correct?
Three steps, no extra software needed. A terminal is enough:
- Check the docs. The example address in the provider's documentation is usually the form of base URL it expects. First see whether it includes
/v1. - Read the tool's hint. Many tools show a note under the input box such as "will append /chat/completions." Go by what the tool's interface says.
- Verify with curl. Replace the placeholders below with your own values:
curl -i <BASE_URL>/models \
-H "Authorization: Bearer <YOUR_API_KEY>"
A 200 response with a model list means both the address and the key work. A 401 means the address is reachable but there is a problem with the key. A 404 means you should go back and check /v1. Whether a /models path exists depends on the service itself, and the Anthropic format uses different auth headers, so follow the official docs.
For the basics of API keys, see What is an API key? Five things beginners should know before using an AI API. Never paste your key anywhere public.
Why does changing the base URL switch the service?
Because many services implement the same request format. The two common ones are the OpenAI format and the Anthropic format. As long as the other side is compatible with one of them, the tool does not care who is behind it. It simply sends requests to the address you entered.
So switching services usually means changing three things: the base URL, the API key, and the model name. Model names differ between providers, so use the names the provider gives you.
AGI Plan as an example: changing just one address
AGI Plan (agiplan.dev) is a multi-provider LLM aggregation gateway. It is sold as a monthly subscription, paid in RMB, with no overseas credit card needed. AGI Plan is a commercial partner of cdnping. It is compatible with both the OpenAI and Anthropic API formats, so tools such as Claude Code, Codex, and OpenCode can connect by changing one address. Claude Code does not need a Claude account, and Codex does not need a ChatGPT account.
Setup takes three steps: sign up with an emailed verification code, choose a plan and create a key, and change one setting in your tool. For the exact address to use and the name of the setting in each tool, see the step-by-step guide at https://agiplan.dev/startup. Follow the guide, since the syntax differs between tools.
Two points to note. The service states clearly that it is not an officially authorized channel. Some models are marked "overseas only," and availability is listed at https://agiplan.dev/models.
How do you confirm the connection works after changing the address?
- On the cdnping home page (/en) you can measure the browser's first-connection and round-trip times to each AI API, which helps you tell a slow network from a misconfiguration.
- For timeouts or occasional failures, check the probe results for the relevant service at /en/status first, then decide whether the problem is your configuration.
- For background on latency, see /en/learn/ai-api-latency-china.
If you are still deciding whether to use the web app, a mobile app, or the API, start with How to start using AI: web, app, or API first.
Next steps
- Find the "API address / Base URL" input box in your tool and check whether it expects
/v1to be included. - Verify with the curl command above.
- If you want to use Claude Code or Codex, try AGI Plan's setup guide. It changes only one setting, and if it does not suit you, you can switch back to your original address.