API 参考
OneKeyLLM 暴露的 /v1 端点简明参考。
Base URL:
用户认证:
Authorization: Bearer sk-lazytech-...
Admin 端点使用单独的 admin bearer。根据 OpenAPI schema,/v1/models 和
/v1/ping 等公开端点不需要 bearer。
| Method | Path | 说明 |
|---|
GET | /v1/ping | API ping。 |
GET | /v1/models | 列出模型目录。 |
GET | /v1/models/{model} | 获取单个模型元数据。 |
| Method | Path | 说明 |
|---|
POST | /v1/responses | 创建 Responses API 响应,stream=true 时使用 SSE。 |
GET | /v1/responses/{response_id} | 获取响应。 |
POST | /v1/chat/completions | 将 Chat Completions 转发到配置的上游。 |
POST | /v1/conversations | 创建 conversation 容器。 |
GET | /v1/conversations/{conversation_id} | 获取 conversation。 |
POST | /v1/conversations/{conversation_id} | 更新 conversation。 |
DELETE | /v1/conversations/{conversation_id} | 删除 conversation。 |
curl https://api.tokapi.ai/v1/responses \
-H "Authorization: Bearer $ONEKEYLLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"input": "Write a one sentence release note."
}'
最小 body 需要 model。input 可按 Responses 格式包含文本、消息、图片、
文件或工具结果。
| Method | Path | 说明 |
|---|
POST | /v1/messages | 通过 Anthropic Messages 创建 Claude 消息。 |
POST | /v1/messages/count_tokens | 计算 Claude token。 |
curl https://api.tokapi.ai/v1/messages \
-H "Authorization: Bearer $ONEKEYLLM_API_KEY" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 128,
"messages": [{ "role": "user", "content": "Reply with ok" }]
}'
| Method | Path | 说明 |
|---|
POST | /v1/files | 上传 multipart form data。 |
PUT | /v1/files/{path} | 通过请求 body 流式上传文件。 |
| Method | Path | 说明 |
|---|
GET | /v1/usage | 当前认证 API 密钥的预算。 |
GET | /v1/usage/account_capacity | 按账号估算剩余容量。 |
POST | /v1/usage/account_capacity/refresh | 刷新容量估算。 |
| Method | Path | 说明 |
|---|
POST | /v1/auth/email/send | 发送登录验证码。 |
POST | /v1/auth/token | 创建用户 JWT。 |
GET | /v1/auth/verify | 验证用户 JWT。 |
| Status | 含义 |
|---|
400 | body 无效或模型不可用。 |
401 | 缺少密钥或密钥无效。 |
402 | API 密钥预算已耗尽。 |
502 | 上游失败。 |
503 | Provider、repository 或容量不可用。 |