工具集成
将 MyTokenGate 与流行的 AI 工具和平台集成的指南。
AI 代码编辑器
Claude Code
Anthropic 的 AI 驱动终端编程助手。
Cursor
AI 优先的代码编辑器,内置 AI 辅助功能。
Cline
VS Code 自主编程代理。
Hermes
Nous Research 开发的自学习 AI 代理框架。
OpenClaw
开源的多平台个人 AI 助手框架。
聊天应用
Chatbox
跨平台桌面聊天应用。
ChatHub
多 AI 聊天机器人的浏览器扩展。
SillyTavern
带角色定制的 AI 聊天前端。
平台
Dify
LLM 应用开发平台。
Base URL 配置指南
不同工具对 Base URL 的要求不同,请参考下表进行配置:
| 工具 | Base URL | 说明 |
|---|---|---|
| OpenAI SDK | https://gateway.mytokengate.com/v1 | SDK 会自动追加 /chat/completions |
| Anthropic SDK | https://gateway.mytokengate.com/v1 | SDK 会自动追加 /messages |
| Claude Code | https://gateway.mytokengate.com | 工具会自动追加 /v1/messages |
| Continue (VSCode) | https://gateway.mytokengate.com | 工具会自动追加版本路径 |
| Cline (VSCode) | https://gateway.mytokengate.com | 工具会自动追加版本路径 |
| LangChain | https://gateway.mytokengate.com/v1 | 直接传递给底层 SDK |
| Cursor IDE | https://gateway.mytokengate.com/v1 | OpenAI 兼容端点 |
| Hermes Agent | https://gateway.mytokengate.com/v1 | 使用 custom provider 配置 |
| OpenClaw | https://gateway.mytokengate.com/v1 | 自定义提供商配置 |
| curl / HTTP | https://gateway.mytokengate.com/v1 | 在请求中使用完整路径 |
配置规则
- 如果工具提到「OpenAI 兼容」或使用官方 SDK → 包含
/v1 - 如果工具是 AI 助手插件(Continue、Cline、Claude Code)→ 不包含
/v1
协议选择建议
MyTokenGate Gateway 支持多协议访问,内部有协议转换机制。使用模型的原生协议可获得最佳兼容性:
| 模型系列 | 原生协议 | 推荐配置方式 |
|---|---|---|
| Claude | Anthropic | 使用 Anthropic SDK 或 Anthropic 提供商设置 |
| GPT | OpenAI | 使用 OpenAI SDK 或 OpenAI Compatible 设置 |
| Gemini | OpenAI | 使用 OpenAI Compatible 设置 |
| DeepSeek | OpenAI | 使用 OpenAI Compatible 设置 |
| 国产模型 | OpenAI | 使用 OpenAI Compatible 设置 |
为什么选择原生协议?
- 更好的功能兼容性(如 Claude 的 extended thinking)
- 更少的参数转换损耗
- 更完整的错误信息反馈
- 更稳定的表现
工具特定配置示例
Claude Code
在 settings.json 中添加:
{
"env": {
"ANTHROPIC_BASE_URL": "https://gateway.mytokengate.com",
"ANTHROPIC_API_KEY": "sk-your-api-key-here"
}
}注意:不要包含 /v1
Continue (VSCode)
在 config.json 中添加:
{
"models": [{
"title": "MyTokenGate Claude",
"provider": "anthropic",
"apiBase": "https://gateway.mytokengate.com",
"apiKey": "tg-your-api-key"
}]
}注意:使用 apiBase,不包含 /v1
Cline (VSCode)
在设置中添加:
{
"api": {
"provider": "anthropic",
"baseUrl": "https://gateway.mytokengate.com",
"apiKey": "tg-your-api-key"
}
}注意:不要包含 /v1
Cursor IDE
打开 Settings → Models,配置:
Base URL: https://gateway.mytokengate.com/v1
API Key: tg-your-api-key注意:需要包含 /v1(OpenAI 格式)
Hermes Agent
编辑 ~/.hermes/cli-config.yaml:
model:
default: "claude-opus-4-6"
provider: "custom"
base_url: "https://gateway.mytokengate.com/v1"
api_key: "tg-your-api-key"OpenClaw
编辑 ~/.openclaw/openclaw.json:
{
models: {
providers: {
"mytokengate": {
baseUrl: "https://gateway.mytokengate.com/v1",
apiKey: "tg-your-api-key",
api: "openai-completions",
},
},
},
agents: { defaults: { model: { primary: "mytokengate/claude-opus-4-6" } } },
}OpenAI SDK
from openai import OpenAI
client = OpenAI(
base_url="https://gateway.mytokengate.com/v1",
api_key="tg-your-api-key"
)Anthropic SDK
from anthropic import Anthropic
client = Anthropic(
base_url="https://gateway.mytokengate.com/v1",
api_key="tg-your-api-key"
)Last updated on