Source: https://aiprimetech.io/zh/docs/getting-started/base-urls/ [首页](/zh/) / [文档](/zh/docs/) / 基础 URL # 基础 URL 最容易让人出错的设置:各客户端需要哪个 URL,以及是否应包含 /v1 后缀。 复制页面 [ 以 Markdown 查看](/zh/docs/getting-started/base-urls.md) [ 向 ChatGPT 提问](https://chatgpt.com/?q=Read%20https%3A//aiprimetech.io/docs/getting-started/base-urls.md%20and%20answer%20questions%20about%20it.%20Start%20with%20a%20short%20summary.) [ 在 Claude 中提问](https://claude.ai/new?q=Read%20https%3A//aiprimetech.io/docs/getting-started/base-urls.md%20and%20answer%20questions%20about%20it.%20Start%20with%20a%20short%20summary.) 几乎所有集成失败都是基础 URL 配置错误所致。本页明确说明应如何设置,可作为参考。 ## 规则 | 客户端 | 将基础 URL 设置为 | 随后调用 | Anthropic SDK(Python / TS) | https://aiprimetech.io | https://aiprimetech.io/v1/messages | Claude Code | https://aiprimetech.io | https://aiprimetech.io/v1/messages | OpenAI SDK(Python / TS) | https://aiprimetech.io/v1 | https://aiprimetech.io/v1/chat/completions | LangChain / LiteLLM / Cursor | https://aiprimetech.io/v1 | https://aiprimetech.io/v1/chat/completions Anthropic 客户端:不包含 /v1。OpenAI 客户端:包含 /v1. Anthropic SDK 会追加 /v1/messages 到你提供的任何基础 URL 后;OpenAI SDK 则仅追加 /chat/completions。将 /v1 添加到 Anthropic 基础 URL 后,会使请求发往 /v1/v1/messages,从而返回 404。 ## 如何判断配置错误 | 你看到 | 含义 | 404 ,且路径中包含 /v1/v1/ | 你添加了 /v1 到 Anthropic 风格的基础 URL 后。请将其移除。 | 404 在 /chat/completions ,但不包含 /v1 | 你遗漏了 /v1 ,未将其包含在 OpenAI 风格的基础 URL 中。请将其添加。 | 404 在 /v1/chat/completions ,来自 Anthropic 工具 | 该工具使用 Messages,而非 Chat Completions。请使用 Anthropic 基础 URL 和端点。 | 连接正常,但每次调用都返回 401 | URL 正确,但认证请求头不符合该格式。请参阅 [身份验证](/zh/docs/getting-started/authentication/). ## 不使用任何 SDK 进行验证 在将问题归咎于框架之前,这是确认 URL 和密钥正确的最快方式: ``` Copy"c"># should return JSON with a "data" array of model ids curl -s -o /dev/null -w "%{http_code}\n" https://aiprimetech.io/v1/models \ -H "Authorization: Bearer $CLAUDEAPIKEY" ``` A 200 表示 URL 和密钥均正确,剩余问题都出在客户端配置中。 [身份验证请求头和环境变量](/zh/docs/getting-started/authentication/)[故障排查从症状入手调试](/zh/docs/guides/troubleshooting/)[概览端点参考](/zh/docs/api-reference/overview/) [上一页模型与密钥组](/zh/docs/getting-started/models/)[下一页首次请求详解](/zh/docs/getting-started/first-request/)