> ## Documentation Index
> Fetch the complete documentation index at: https://docs.llmeasy.ru/llms.txt
> Use this file to discover all available pages before exploring further.

# Base URL 怎么填？

> 说明 Claude Code、Codex、Cursor、Cline 等工具中 Base URL、/v1 路径、API Key 和 Model ID 的匹配方式。

## 简短答案

Base URL 要跟工具协议匹配。Claude Code 通常使用 Anthropic-compatible 根地址；Codex、Cursor、Cline、OpenCode、OpenClaw 等外部工具通常使用 OpenAI-compatible `/v1` 地址。

在 LLMEasy 中：

| 使用场景                               | Base URL                    |
| ---------------------------------- | --------------------------- |
| Claude Code / Anthropic-compatible | `https://www.llmeasy.ru`    |
| Codex / OpenAI-compatible          | `https://www.llmeasy.ru/v1` |
| Cursor、Cline、OpenCode、OpenClaw     | `https://www.llmeasy.ru/v1` |

不要自己猜路径。API Key、Base URL 和 Model ID 必须来自同一个 provider / gateway。

## 为什么会有不同 Base URL

不同 SDK 对路径拼接方式不同。

| 协议或工具类型                  | 常见行为                                         |
| ------------------------ | -------------------------------------------- |
| OpenAI-compatible SDK    | 通常基于 `/v1` 访问 chat completions、responses 等资源 |
| Anthropic-compatible SDK | 通常由 SDK 拼接消息接口路径，不应重复添加 `/v1`                |
| 工具内置 provider            | 可能自动补路径，也可能要求你填写完整 Base URL                  |

同一个模型名不代表可以使用同一个 Base URL。真正需要匹配的是：工具协议、Base URL、API Key、Key group 和 Model ID。

## 推荐速查

| 工具                     | 推荐配置                                                      |
| ---------------------- | --------------------------------------------------------- |
| Claude Code            | `https://www.llmeasy.ru`，使用 Claude 分组 API Key             |
| Claude Desktop Gateway | 按 Gateway 页面说明填写，注意 auth scheme                           |
| Codex CLI              | `https://www.llmeasy.ru/v1`，使用 GPT 分组 API Key             |
| Cursor                 | `https://www.llmeasy.ru/v1`，使用 GPT 分组 API Key             |
| Cline                  | `https://www.llmeasy.ru/v1`，选择 OpenAI Compatible provider |
| OpenCode / OpenClaw    | `https://www.llmeasy.ru/v1`，使用 GPT 分组 API Key             |

## 常见错误

| 报错或现象             | 可能原因                                                  |
| ----------------- | ----------------------------------------------------- |
| `404 Not Found`   | Base URL 路径和 SDK 期望不一致                                |
| `model not found` | Model ID 不属于当前 Key group 或 provider                   |
| `invalid_api_key` | API Key 和 Base URL 不属于同一服务                            |
| 认证通过但模型不可用        | Key group 和 Model ID 不匹配                              |
| 请求一直失败            | 把 Anthropic-compatible 地址填进 OpenAI-compatible 工具，或反过来 |

## 推荐排查顺序

1. 先确认工具要求 OpenAI-compatible 还是 Anthropic-compatible。
2. 检查 Base URL 是否和工具协议匹配。
3. 检查 API Key 是否来自同一个服务。
4. 检查 Model ID 是否来自<a href={"https://www.llmeasy.ru/pricing"}>模型广场</a>，并属于当前 Key group。
5. 发送一个最小请求测试，例如只问一句 `hello`。

## 代码示例

OpenAI-compatible 工具通常使用 `/v1` 地址：

```python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://www.llmeasy.ru/v1"
)

response = client.chat.completions.create(
    model="your-model-id",
    messages=[{"role": "user", "content": "hello"}]
)
```

Claude / Anthropic-compatible 场景通常使用根地址：

```python theme={null}
import anthropic

client = anthropic.Anthropic(
    api_key="YOUR_API_KEY",
    base_url="https://www.llmeasy.ru"
)

message = client.messages.create(
    model="your-claude-model-id",
    max_tokens=1024,
    messages=[{"role": "user", "content": "hello"}]
)
```

## 关于 LLMEasy

LLMEasy 同时提供 Anthropic-compatible 和 OpenAI-compatible 的接入方式。你可以在同一个 dashboard 管理 API Key、余额和用量记录，但每个客户端仍然要填写它实际支持的协议地址。

简单记法：Claude Code 看 `https://www.llmeasy.ru`；Codex、Cursor、Cline、OpenCode、OpenClaw 看 `https://www.llmeasy.ru/v1`。

## Related docs

* [OpenAI-compatible API 和 Anthropic-compatible API 有什么区别？](/zh/faq/concepts/openai-compatible-vs-anthropic-compatible)
* [如何选择合适的 AI 模型？](/zh/faq/model-calling/model-selection-guide)
* [Codex CLI 中 model\_provider、base\_url 和 wire\_api 是什么？](/zh/faq/codex/model-provider-base-url-wire-api)
* [Cline 如何配置 OpenAI-compatible API？](/zh/faq/cline/openai-compatible-api)
