认证指南
获取 API Key
Section titled “获取 API Key”- 登录 EasyTakeAI 控制台
- 进入「API 密钥」页面
- 点击「创建密钥」
- 复制并安全保存生成的密钥
使用 API Key
Section titled “使用 API Key”在每个 API 请求的 Header 中携带 API Key:
curl -X POST https://api.easytakeai.com/v1/chat/completions \ -H "Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"model": "easytake-pro", "messages": [{"role": "user", "content": "你好"}]}'SDK 方式
Section titled “SDK 方式”import { EasyTakeAI } from 'easytakeai';
const client = new EasyTakeAI({ apiKey: 'sk-xxxxxxxxxxxxxxxxxxxx',});| HTTP 状态码 | 错误类型 | 说明 |
|---|---|---|
| 401 | invalid_api_key | API Key 无效或已过期 |
| 401 | missing_api_key | 请求未携带 API Key |
| 403 | insufficient_permissions | API Key 权限不足 |
| 429 | rate_limit_exceeded | 超出速率限制 |
安全最佳实践
Section titled “安全最佳实践”- 使用环境变量 — 不要在代码中硬编码 API Key
- 定期轮换 — 建议每 90 天更换一次 API Key
- 最小权限 — 为每个应用创建独立的 API Key
- 监控使用 — 在控制台中监控 API 调用情况
- IP 白名单 — 生产环境建议配置 IP 白名单
# ✅ 推荐:使用环境变量EASYTAKEAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxx// ✅ 推荐:从环境变量读取const client = new EasyTakeAI({ apiKey: process.env.EASYTAKEAI_API_KEY,});
// ❌ 不推荐:硬编码const client = new EasyTakeAI({ apiKey: 'sk-xxxxxxxxxxxxxxxxxxxx',});