Skip to content
StatusGet API key

API reference

Base URL: https://api.thetoken.dev/v1. Every path below is relative to this URL. Anthropic SDKs and Claude Code take the base URL without /v1 (https://api.thetoken.dev) and add /v1/messages themselves.

Authentication: Authorization: Bearer $TOKEN_API_KEY (on /messages and /models,x-api-key works too). The full OpenAPI 3.1 document: /openapi.json.

Models

Every endpoint takes a model ID or its alias. This list comes from the model catalog.

ModelAliasesEndpointsToolsStructured outputImage input
moonshotai/kimi-k3kimi-k3/chat/completions, /responses, /messagesyesyesyes
zai-org/glm-5.3glm-5.3/chat/completions, /responses, /messagesyesyesno
zai-org/glm-5.3-flashglm-5.3-flash/chat/completions, /responses, /messagesyesyesyes
deepseek/deepseek-v4-prodeepseek-v4-pro/chat/completions, /responses, /messagesyesyesno
deepseek/deepseek-v4.1-flashdeepseek-v4.1-flash/chat/completions, /responses, /messagesyesyesyes
openai/gpt-oss-120bgpt-oss-120b/chat/completions, /responses, /messagesyesyesno
openai/gpt-oss-20bgpt-oss-20b/chat/completions, /responses, /messagesyesyesno
google/gemma-4-31b-itgemma-4-31b-it/chat/completions, /responses, /messagesyesyesyes
google/gemma-4-26b-a4b-itgemma-4-26b-a4b-it/chat/completions, /responses, /messagesyesyesyes
baai/bge-m3bge-m3/embeddings——no
meta-llama/llama-4-maverickllama-4-maverick/chat/completions, /responses, /messagesnonot statedyes

POST /chat/completions

Create a chat completion. OpenAI Chat Completions. With stream: true the reply comes as server-sent events (data: {...} lines, then data: [DONE]); the last chunk before [DONE] carries usage unless stream_options.include_usage is false.

FieldTypeRequiredDescription
modelstring (model)yesA chat model ID or alias from the catalog. Without tool calling: meta-llama/llama-4-maverick.
messagesarray of ChatMessageyesThe conversation so far.
max_tokensintegernoMaximum output tokens. Lowered automatically when your balance or the key's spending limit cannot pay for it.
max_completion_tokensintegernoSame as max_tokens (newer OpenAI name).
streambooleannoStream the reply as server-sent events.
stream_optionsobjectnoinclude_usage: send usage in the last chunk (on unless set to false).
temperaturenumberno
top_pnumberno
stopstring | array of stringno
toolsarray of objectnoFunction tools ({"type": "function", "function": {...}}). Refused with 400 by models without tool calling.
tool_choicestring | objectnoauto, none, required, or a specific function.
response_formatobjectno{"type": "json_object"} or {"type": "json_schema", "json_schema": {...}} on models with structured output.
reasoning_effortstringnoFor example low, medium or high, on reasoning models that accept an effort level (see each model's page).
Request
curl https://api.thetoken.dev/v1/chat/completions \
-H "Authorization: Bearer $TOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "zai-org/glm-5.3-flash",
"messages": [
{
"role": "user",
"content": "Say hello in one short sentence."
}
],
"max_tokens": 256
}'
Response
{
"id": "chatcmpl-8f2c1e0b6a",
"object": "chat.completion",
"created": 1761379200,
"model": "zai-org/glm-5.3-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello, nice to meet you!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 14,
"completion_tokens": 9,
"total_tokens": 23,
"prompt_tokens_details": {
"cached_tokens": 0
}
}
}

Errors: 400 The request is invalid, for example tools sent to a model without tool calling.; 401 The key is missing, invalid, disabled, expired or used up.; 403 Insufficient balance or key spending limit, or the model is not allowed for this key.; 429 Per-account rate limit (requests per minute) or concurrency limit (requests in flight) reached.; 503 No provider can serve the model for this key's group right now. See errors and rate limits.

POST /responses

Create a response. OpenAI Responses API. Send input as a string or as a list of input items. Streams use the Responses event types (response.output_text.delta, ..., response.completed).

FieldTypeRequiredDescription
modelstring (model)yesA chat model ID or alias from the catalog. Without tool calling: meta-llama/llama-4-maverick.
inputstring | array of objectyes
instructionsstringnoSystem instructions.
max_output_tokensintegernoMaximum output tokens. Lowered automatically when your balance or the key's spending limit cannot pay for it.
streambooleanno
toolsarray of objectno
textobjectnoOutput format, for example {"format": {"type": "json_schema", ...}}.
reasoningobjectnoFor example {"effort": "low"}.
Request
curl https://api.thetoken.dev/v1/responses \
-H "Authorization: Bearer $TOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-120b",
"input": "Name three prime numbers.",
"max_output_tokens": 512
}'

Errors: 400 The request is invalid, for example tools sent to a model without tool calling.; 401 The key is missing, invalid, disabled, expired or used up.; 403 Insufficient balance or key spending limit, or the model is not allowed for this key.; 429 Per-account rate limit (requests per minute) or concurrency limit (requests in flight) reached.; 503 No provider can serve the model for this key's group right now. See errors and rate limits.

POST /messages

Create a message (Anthropic format). Anthropic Messages API at https://api.thetoken.dev/v1/messages, for Anthropic SDKs and tools such as Claude Code. Authenticate with Authorization: Bearer or x-api-key. Errors raised by the relay come in Anthropic's format ({"type": "error", "error": {...}}); key and rate-limit errors, checked before the request is read, come in the OpenAI format.

FieldTypeRequiredDescription
modelstring (model)yesA chat model ID or alias from the catalog. Without tool calling: meta-llama/llama-4-maverick.
max_tokensintegeryesMaximum output tokens. Lowered automatically when your balance or the key's spending limit cannot pay for it.
messagesarray of objectyes{"role": "user" | "assistant", "content": string | blocks}.
systemstring | array of objectno
streambooleanno
toolsarray of objectnoAnthropic tools (name, description, input_schema). Refused with 400 by models without tool calling.
tool_choiceobjectno
temperaturenumberno
Request
curl https://api.thetoken.dev/v1/messages \
-H "Authorization: Bearer $TOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "moonshotai/kimi-k3",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Explain failover in one paragraph."
}
]
}'
Response
{
"id": "msg_01a9c3e7",
"type": "message",
"role": "assistant",
"model": "moonshotai/kimi-k3",
"content": [
{
"type": "text",
"text": "Failover means that when one provider fails, the request is sent to the next one."
}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 15,
"output_tokens": 21
}
}

Errors: 400 The request is invalid, for example tools sent to a model without tool calling.; 401 The key is missing, invalid, disabled, expired or used up.; 403 Insufficient balance or key spending limit, or the model is not allowed for this key.; 429 Per-account rate limit (requests per minute) or concurrency limit (requests in flight) reached.; 503 No provider can serve the model for this key's group right now. See errors and rate limits.

POST /embeddings

Create embeddings. OpenAI Embeddings. input is a string or a list of strings; each result is a list of floats.

FieldTypeRequiredDescription
modelstring (model)yesAn embedding model ID or alias from the catalog.
inputstring | array of stringyesText, or a list of texts, to embed.
encoding_formatstringno
Request
curl https://api.thetoken.dev/v1/embeddings \
-H "Authorization: Bearer $TOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "baai/bge-m3",
"input": [
"The quick brown fox",
"Le renard brun"
]
}'
Response
{
"object": "list",
"model": "baai/bge-m3",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [
0.0123,
-0.0456,
0.0789
]
},
{
"object": "embedding",
"index": 1,
"embedding": [
0.0119,
-0.0441,
0.0802
]
}
],
"usage": {
"prompt_tokens": 10,
"total_tokens": 10
}
}

Errors: 400 The request is invalid, for example tools sent to a model without tool calling.; 401 The key is missing, invalid, disabled, expired or used up.; 403 Insufficient balance or key spending limit, or the model is not allowed for this key.; 429 Per-account rate limit (requests per minute) or concurrency limit (requests in flight) reached.; 503 No provider can serve the model for this key's group right now. See errors and rate limits.

GET /models

List models. The models your key can use (all catalog models, or the key's allow-list). The public catalog with prices and providers, without a key: https://thetoken.dev/models.json.

Request
curl https://api.thetoken.dev/v1/models \
-H "Authorization: Bearer $TOKEN_API_KEY"
Response
{
"object": "list",
"success": true,
"data": [
{
"id": "moonshotai/kimi-k3",
"object": "model",
"created": 1626777600
},
{
"id": "baai/bge-m3",
"object": "model",
"created": 1626777600
}
]
}

Errors: 401 The key is missing, invalid, disabled, expired or used up. See errors and rate limits.