API Key 管理
通过 Portal 控制台或 API 管理你的 API Key。所有接口都通过 https://api.dsesnet.com 访问。
Portal API(Key 管理)
需要使用 Supabase JWT Token 认证(从控制台登录后获取)。
| 方法 | 路径 | 说明 |
|---|---|---|
GET | /portal/keys | 列出你的所有 Key |
POST | /portal/keys | 创建新 Key |
PATCH | /portal/keys/:id | 更新 Key(名称、模型白名单) |
DELETE | /portal/keys/:id | 吊销 Key |
创建 Key
curl -X POST https://api.dsesnet.com/portal/keys \
-H "Authorization: Bearer YOUR_JWT" \
-H "Content-Type: application/json" \
-d '{"name": "my-app", "allowed_models": ["deepseek-chat"]}' {
"data": {
"id": "uuid-xxx",
"raw_key": "gw-my-app-abc123...",
"name": "my-app",
"allowed_models": ["deepseek-chat"]
}
} raw_key 仅在创建时返回一次,请妥善保管。
Key 属性
| 字段 | 类型 | 说明 |
|---|---|---|
name | string | 可读的标签名称 |
allowed_models | string[] | 模型白名单(空数组 = 允许所有模型) |
spending_limit | number | 最大消费额度(人民币) |
limit_reset | string | "daily"、"weekly"、"monthly" 或 "never" |
expires_at | string | ISO 8601 格式的过期时间 |
is_active | boolean | 启用/禁用 Key |
查询 Key 信息
使用 API Key 本身查询余额和用量(无需 JWT):
curl https://api.dsesnet.com/v1/auth/key \
-H "Authorization: Bearer gw-your-key" {
"data": {
"label": "gw-my-app-...",
"limit": 100.0,
"usage": 25.5,
"limit_remaining": 74.5,
"limit_reset": "monthly"
}
}