API Reference
TokenFast exposes OpenAI-compatible endpoints. All requests should be sent to the base URL with your API key in the Authorization header.
Base URL: https://api.tokenfast.ai/v1Endpoints
- POST /v1/chat/completions -- Create a chat completion
- GET /v1/models -- List available models
- GET /v1/usage/keys -- Per-key usage for your account
/v1/chat/completionsCreates a model response for the given chat conversation. This is the primary endpoint for interacting with language models.
Request Body
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | ID of the model to use (e.g., gpt-4o, claude-sonnet-4-6, gemini-2.5-pro). |
messagesrequired | array | A list of messages comprising the conversation. Each message has a role (system, user, or assistant) and content. |
temperature | number | Sampling temperature between 0 and 2. Higher values make output more random. Default: 1. |
max_tokens | integer | Maximum number of tokens to generate in the response. Default varies by model. |
top_p | number | Nucleus sampling parameter. An alternative to temperature. Default: 1. |
stream | boolean | If true, partial message deltas will be sent as server-sent events. Default: false. |
stop | string | array | Up to 4 sequences where the API will stop generating further tokens. |
presence_penalty | number | Penalizes new tokens based on whether they appear in the text so far. Range: -2.0 to 2.0. |
frequency_penalty | number | Penalizes new tokens based on their existing frequency in the text. Range: -2.0 to 2.0. |
tools | array | A list of tools (functions) the model may call. Each tool is defined with a type, function name, description, and parameters schema. |
tool_choice | string | object | Controls which tool is called. Options: "none", "auto", or a specific tool object. |
response_format | object | An object specifying the format of the response. Use {"type": "json_object"} for JSON mode. |
Message Object
| Field | Type | Description |
|---|---|---|
rolerequired | string | The role of the message author: "system", "user", or "assistant". |
contentrequired | string | The content of the message. |
name | string | An optional name for the participant. |
Example Request
curl https://api.tokenfast.ai/v1/chat/completions \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."}
],
"temperature": 0.7,
"max_tokens": 512
}'Example Response
{
"id": "chatcmpl-abc123def456",
"object": "chat.completion",
"created": 1712345678,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Quantum computing uses quantum bits (qubits) that can exist in multiple states simultaneously..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 156,
"total_tokens": 184
}
}/v1/modelsLists the currently available models along with their capabilities and pricing information. This endpoint does not require authentication.
Parameters
This endpoint takes no parameters.
Example Request
curl https://api.tokenfast.ai/v1/modelsExample Response
{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"owned_by": "openai",
"capabilities": ["chat", "code", "vision", "function_calling", "json_mode"],
"context_window": 128000,
"pricing": {
"input_per_million": 2.50,
"output_per_million": 10.00
}
},
{
"id": "claude-sonnet-4-6",
"object": "model",
"owned_by": "anthropic",
"capabilities": ["chat", "code", "vision", "function_calling"],
"context_window": 200000,
"pricing": {
"input_per_million": 3.00,
"output_per_million": 15.00
}
}
]
}/v1/usage/keysReturns a per-key usage report for your whole account: spend, request count and token totals for every API key, bucketed by calendar day (Asia/Shanghai). Authenticate with your usage query key (uk-...) — a read-only credential generated in Dashboard → Settings, separate from your LLM keys.
Parameters
start | date, optional | Range start, YYYY-MM-DD (inclusive, Asia/Shanghai days). Defaults to 29 days before end. |
end | date, optional | Range end, YYYY-MM-DD (inclusive). Defaults to today. Max range: 92 days. |
Example Request
curl "https://api.tokenfast.ai/v1/usage/keys?start=2026-06-09&end=2026-07-08" \
-H "Authorization: Bearer uk-your-usage-query-key"Example Response
{
"object": "usage.keys",
"start": "2026-06-09",
"end": "2026-07-08",
"timezone": "Asia/Shanghai",
"keys": [
{
"name": "production-backend",
"hint": "sk-...Xy4a",
"status": "ACTIVE",
"blocked": false,
"created_at": "2026-07-01T02:10:00.000Z",
"total": {
"spend_usd": 12.48,
"requests": 1042,
"prompt_tokens": 180311,
"completion_tokens": 95204
},
"daily": [
{
"date": "2026-07-08",
"spend_usd": 1.02,
"requests": 88,
"prompt_tokens": 15200,
"completion_tokens": 8100
}
]
}
]
}Revoked keys with usage inside the range are included (status REVOKED), so historical reports stay complete. Days with no traffic have no daily row.
Rate Limits
30 requests per minute per query key, 120 per minute per IP.
Exceeding the limit returns 429 with a Retry-After header. The query key cannot call models, so this limit never affects your LLM traffic. For daily reporting, one request per day per account is enough.
Authentication
All endpoints (except GET /v1/models) require authentication via a Bearer token in the Authorization header:
Authorization: Bearer sk-your-api-keyAPI keys can be created and managed from your Dashboard. If you send a request without a valid key, you will receive a 401 Unauthorized response.
Rate Limiting
Rate limits are applied per API key. When a rate limit is exceeded, the API returns a 429 status code. Response headers include:
| Header | Description |
|---|---|
| x-ratelimit-limit-requests | Maximum requests per minute for your key |
| x-ratelimit-remaining-requests | Remaining requests in the current window |
| x-ratelimit-limit-tokens | Maximum tokens per minute for your key |
| x-ratelimit-remaining-tokens | Remaining tokens in the current window |
| retry-after | Seconds to wait before retrying (on 429 responses) |
For more details, see the Error Codes page.