首次调用 API
AIGateway 使用与 OpenAI 兼容的 API 格式。修改 base_url 即可用 OpenAI/Anthropic SDK 访问全部模型。
接入信息
| PARAM | VALUE |
|---|---|
| base_url (OpenAI) | https://api.aigateway.ltd/v1 |
| base_url (Anthropic) | https://api.aigateway.ltd/anthropic |
| api_key | 控制台创建(sk- 开头) |
| model | auto / deepseek-chat / deepseek-coder / qwen-plus / qwen-turbo / qwen-max |
第一个请求
curl https://api.aigateway.ltd/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${AIGATEWAY_API_KEY}" \
-d '{
"model": "auto",
"messages": [{"role": "user", "content": "你好!"}],
"stream": true
}'model 设为 auto 时,网关按请求复杂度自动选择档位模型,按实际命中模型计价;简单问题成本可降低 90% 以上。
接入 Agent 工具
Claude Code、GitHub Copilot、OpenCode、Cursor 等工具可直接将 AIGateway 作为后端模型,无需编写代码:在工具的模型配置中选择 OpenAI 兼容提供商,填入 base_url 与 api_key 即可。详见《Agent 工具接入》。