跳转到主要内容

简短答案

Base URL 要跟工具协议匹配。Claude Code 通常使用 Anthropic-compatible 根地址;Codex、Cursor、Cline、OpenCode、OpenClaw 等外部工具通常使用 OpenAI-compatible /v1 地址。 在 LLMEasy 中:
使用场景Base URL
Claude Code / Anthropic-compatiblehttps://www.llmeasy.ru
Codex / OpenAI-compatiblehttps://www.llmeasy.ru/v1
Cursor、Cline、OpenCode、OpenClawhttps://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 Codehttps://www.llmeasy.ru,使用 Claude 分组 API Key
Claude Desktop Gateway按 Gateway 页面说明填写,注意 auth scheme
Codex CLIhttps://www.llmeasy.ru/v1,使用 GPT 分组 API Key
Cursorhttps://www.llmeasy.ru/v1,使用 GPT 分组 API Key
Clinehttps://www.llmeasy.ru/v1,选择 OpenAI Compatible provider
OpenCode / OpenClawhttps://www.llmeasy.ru/v1,使用 GPT 分组 API Key

常见错误

报错或现象可能原因
404 Not FoundBase URL 路径和 SDK 期望不一致
model not foundModel ID 不属于当前 Key group 或 provider
invalid_api_keyAPI 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 是否来自模型广场,并属于当前 Key group。
  5. 发送一个最小请求测试,例如只问一句 hello

代码示例

OpenAI-compatible 工具通常使用 /v1 地址:
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 场景通常使用根地址:
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