Skip to content

API Reference

All API requests use the base URL https://tokenpass.cloud/v1.

Authentication

Send the TokenPass API key as a Bearer token:

http
Authorization: Bearer <TOKENPASS_API_KEY>

List models

GET /v1/models returns the model IDs available to the current API key.

bash
curl https://tokenpass.cloud/v1/models \
  -H "Authorization: Bearer $TOKENPASS_API_KEY"

Chat Completions

POST /v1/chat/completions accepts an OpenAI-compatible message list.

json
{
  "model": "gpt-5-mini",
  "messages": [
    { "role": "system", "content": "You are a concise assistant." },
    { "role": "user", "content": "Explain token caching." }
  ],
  "stream": false
}

Common fields include model, messages, stream, tools, tool_choice, response_format, and model-supported sampling or reasoning controls.

Responses

POST /v1/responses is required for Responses-only models such as gpt-5.4-pro and supports stateful response items and compatible tools.

bash
curl https://tokenpass.cloud/v1/responses \
  -H "Authorization: Bearer $TOKENPASS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-pro",
    "input": "Review this architecture for failure modes."
  }'

Messages

POST /v1/messages accepts an Anthropic-compatible request.

bash
curl https://tokenpass.cloud/v1/messages \
  -H "Authorization: Bearer $TOKENPASS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Streaming

Set stream to true on an interface and model that support streaming. Clients must process Server-Sent Events incrementally and stop when the interface-specific completion event is received.

bash
curl -N https://tokenpass.cloud/v1/chat/completions \
  -H "Authorization: Bearer $TOKENPASS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5-mini",
    "messages": [{"role": "user", "content": "Count to five."}],
    "stream": true
  }'

Errors

HTTP statusMeaningAction
400Invalid JSON or request parameterCheck the request schema and model-specific fields.
401Missing or invalid API keyCheck the Bearer token and key status.
402/403Balance, quota, or access conditionCheck the Console and model access.
404Unknown model or endpointRefresh IDs with GET /v1/models.
429Rate limit reachedRetry with exponential backoff and jitter.
502/503Temporary upstream unavailabilityRetry idempotent requests with bounded backoff.

Oversized input may also fail when the request exceeds the effective context limit for the selected model and interface.