OneKeyLLM

API 参考

OneKeyLLM 暴露的 /v1 端点简明参考。

Base URL:

https://api.tokapi.ai

用户认证:

Authorization: Bearer sk-lazytech-...

Admin 端点使用单独的 admin bearer。根据 OpenAPI schema,/v1/models/v1/ping 等公开端点不需要 bearer。

Runtime

MethodPath说明
GET/v1/pingAPI ping。
GET/v1/models列出模型目录。
GET/v1/models/{model}获取单个模型元数据。

OpenAI 兼容

MethodPath说明
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。

Responses 示例

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 需要 modelinput 可按 Responses 格式包含文本、消息、图片、 文件或工具结果。

Claude 兼容

MethodPath说明
POST/v1/messages通过 Anthropic Messages 创建 Claude 消息。
POST/v1/messages/count_tokens计算 Claude token。

Messages 示例

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" }]
  }'

Files

MethodPath说明
POST/v1/files上传 multipart form data。
PUT/v1/files/{path}通过请求 body 流式上传文件。

Usage

MethodPath说明
GET/v1/usage当前认证 API 密钥的预算。
GET/v1/usage/account_capacity按账号估算剩余容量。
POST/v1/usage/account_capacity/refresh刷新容量估算。

Auth dashboard

MethodPath说明
POST/v1/auth/email/send发送登录验证码。
POST/v1/auth/token创建用户 JWT。
GET/v1/auth/verify验证用户 JWT。

常见错误

Status含义
400body 无效或模型不可用。
401缺少密钥或密钥无效。
402API 密钥预算已耗尽。
502上游失败。
503Provider、repository 或容量不可用。