TokenPilotAPI documentation
English简体中文繁體中文
Console ↗
API documentationAPI reference

API reference

Browse request examples by protocol and task.

Account permissions and active channels determine which models and protocols you can use. Check the model list and pricing first.

GET /v1/models

Model IDs available to this key.

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

POST /v1/chat/completions

Send a chat request. Add "stream": true and use curl -N to receive server-sent events.

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

Use the Responses format with a model that supports it.

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 format. Provide x-api-key and the protocol version.

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 native request. Insert the model ID in the URL path.

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

Convert text to vectors with an embedding model.

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

Generate an image. For edits, use POST /v1/images/edits and the input format required by the selected model.

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

Create an asynchronous video job with a compatible model. Save the returned job 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}

Poll job status at reasonable intervals. Once complete, retrieve the content if the selected model supports the content endpoint.

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"