TokenPilotAPI 文档
English简体中文繁體中文
控制台 ↗
API 文档API 参考

API 参考

按协议和任务查看请求示例。

可用模型和协议取决于账户权限与已启用的渠道。请先查看模型列表和价格。

GET /v1/models

列出此密钥可用的模型 ID。

curl "https://api.tokentpilot.com/v1/models" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY"

POST /v1/chat/completions

发起对话。将 stream 设为 true 并使用 curl -N 接收流式事件。

curl "https://api.tokentpilot.com/v1/chat/completions" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","messages":[{"role":"user","content":"Reply in one sentence."}]}'

POST /v1/responses

选择支持 Responses 协议的模型,然后使用 input 提交内容。

curl "https://api.tokentpilot.com/v1/responses" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","input":"Summarize this request in one sentence."}'

POST /v1/messages

Anthropic Messages 格式,需传入 x-api-key 和协议版本。

curl "https://api.tokentpilot.com/v1/messages" \
  -H "x-api-key: $TOKENPILOT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","max_tokens":256,"messages":[{"role":"user","content":"Write a short greeting."}]}'

POST /v1beta/models/{model}:generateContent

Gemini 原生请求,在 URL 路径中填写模型 ID。

curl "https://api.tokentpilot.com/v1beta/models/REPLACE_WITH_MODEL_ID:generateContent" \
  -H "x-goog-api-key: $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"Write a short greeting."}]}]}'

POST /v1/embeddings

使用向量模型将文本转换为向量。

curl "https://api.tokentpilot.com/v1/embeddings" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","input":["API integration notes"]}'

POST /v1/images/generations

生成图像。编辑使用 POST /v1/images/edits,参数格式以所选模型为准。

curl "https://api.tokentpilot.com/v1/images/generations" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","prompt":"A ceramic cup on a wooden table in morning light."}'

POST /v1/videos

使用支持该协议的模型创建异步视频任务,保存响应中的任务 ID。

curl "https://api.tokentpilot.com/v1/videos" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"REPLACE_WITH_MODEL_ID","prompt":"A slow camera pan across a quiet harbor."}'

GET /v1/videos/{id}

间隔查询任务状态。任务完成后,如果模型支持内容接口,可下载结果。

curl "https://api.tokentpilot.com/v1/videos/REPLACE_WITH_JOB_ID" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY"

curl -L --output result.mp4 "https://api.tokentpilot.com/v1/videos/REPLACE_WITH_JOB_ID/content" \
  -H "Authorization: Bearer $TOKENPILOT_API_KEY"