工具集成Tool Integration
本节介绍如何在常见的 AI 编码工具中使用平台 API Key。每篇指南都会给出安装、配置、验证和排错步骤,方便你按自己的操作系统完成接入。This section explains how to use the platform API key in common AI coding tools. Each guide covers installation, configuration, verification, and troubleshooting so you can integrate on your own operating system.
已支持的指南Available Guides
Claude Code
在 Windows、macOS 或 Linux 终端中配置 Claude Code,通过 Anthropic 兼容端点接入。Configure Claude Code in a Windows, macOS, or Linux terminal via the Anthropic-compatible endpoint.
Cursor
在 Cursor 中设置 OpenAI 兼容地址、API Key 和可用模型。Set the OpenAI-compatible base URL, API key, and available models in Cursor.
OpenCode
在 OpenCode 中配置 API Key 与模型。Configure the API key and models in OpenCode.
Codex CLI
在 Windows、macOS 或 Linux 终端中配置 Codex CLI,并通过平台调用模型。Configure Codex CLI in a Windows, macOS, or Linux terminal and call models through the platform.
MCP 服务器MCP Server
将 MCP 工具服务器接入支持 MCP 的编码工具。Connect MCP tool servers to coding tools that support MCP.
更多工具More Tools
Claude Desktop、Junie CLI、OpenClaw 等持续接入中。Claude Desktop, Junie CLI, OpenClaw, and more are being added continuously.
通用配置Common Configuration
无论使用哪种工具,接入平台都需要配置以下三个要素:Whichever tool you use, integrating with the platform requires these three settings:
| 配置项Setting | 说明Description |
|---|---|
| Base URL | {BASE_URL}/v1(OpenAI 兼容工具) (OpenAI-compatible tools)或 or {BASE_URL}(Anthropic 兼容工具) (Anthropic-compatible tools) |
| API Key | 在「令牌」页面创建的平台 Token,认证方式为 Bearer <Token>A platform token created on the Tokens page, authenticated as Bearer <Token> |
| 模型Model | 在「模型广场」或 GET /v1/models 查询可用模型Check available models in the Model Square or via GET /v1/models |
配置示例Configuration Examples
环境变量Environment Variables
# OpenAI-compatible tools
OPENAI_API_KEY=sk-your-platform-token
OPENAI_BASE_URL={BASE_URL}/v1
# Anthropic-compatible tools
ANTHROPIC_API_KEY=sk-your-platform-token
ANTHROPIC_BASE_URL={BASE_URL}
OpenAI SDK
from openai import OpenAI
client = OpenAI(
api_key="sk-your-platform-token",
base_url="{BASE_URL}/v1",
)
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "你好"}],
)
print(resp.choices[0].message.content)
使用前须知Before You Start
- 请在本地安全保存 API Key,不要把真实 Key 写入代码仓库、文档或公开截图。Store your API key securely and locally; never put real keys into code repositories, documents, or public screenshots.
- 文中的
YOUR_API_KEY仅是占位符,使用时请替换为自己的平台 Token。YOUR_API_KEYin the docs is only a placeholder; replace it with your own platform token when using. - 各工具对协议和模型能力的要求不同。请以对应工具指南为准。Each tool has different protocol and model capability requirements; follow the corresponding tool guide.
下一步Next Steps
- 认证鉴权Authentication — 查看平台 Token 的认证方式与请求头说明。 — See authentication methods and request headers for platform tokens.
- API 参考API Reference — 查看各接口的请求与响应示例。 — See request and response examples for each endpoint.