AI API 快速开始
这篇文档帮助你用最短路径完成第一次 API 调用。
1. 注册账号
进入 控制台 注册或登录账号。
2. 充值余额
进入 充值页 充值。余额用于 API 调用、AI 方案和云资源。
3. 创建 API Key
进入 API Key 页面 创建 Key。请求时使用:
Authorization: Bearer csk-your-api-key
4. 发起请求
from openai import OpenAI
client = OpenAI(
api_key="csk-your-api-key",
base_url="https://openai.callaiapi.com/v1",
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
常用 Base URL
| 供应商 | Base URL |
|---|---|
| Claude | https://claude.callaiapi.com/v1 |
| OpenAI | https://openai.callaiapi.com/v1 |
| Gemini | https://gemini.callaiapi.com/v1 |
| DeepSeek | https://deepseek.callaiapi.com/v1 |
下一步
- 查看 Claude API 接入
- 查看 DeepSeek API 接入
- 阅读 定价与充值