Base URL
https://tokentab.dev/api/v1Authentication
Free tier ใช้ได้เลยไม่ต้องมี API key (limit ตาม IP) ต้องการ quota สูงขึ้นให้ส่ง key ใน header x-api-key
curl https://tokentab.dev/api/v1/models \
-H "x-api-key: tk_your_api_key"Rate Limits
| แผน | Request/วัน | ราคา |
|---|---|---|
| ฟรี | 100 | $0 |
| Developer | 1,000 | $19/mo |
| Pro | 10,000 | $49/mo |
Rate limit headers are included in every response: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.
GET
/models
List and search LLM models with pricing data.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| q | string | Search by model name or ID |
| provider | string | Filter by provider name (e.g. OpenAI) |
| max_input_cost | number | Max input cost per 1M tokens |
| min_context | number | Min context window (tokens) |
| vision | boolean | Filter vision-capable models |
| function_calling | boolean | Filter function-calling models |
| sort | string | Sort field (default: inputCostPer1M) |
| order | string | asc or desc (default: asc) |
| limit | number | Results per page (max 500, default 100) |
| offset | number | Pagination offset (default 0) |
ตัวอย่าง Request
curl "https://tokentab.dev/api/v1/models?provider=openai&sort=inputCostPer1M&limit=5"ตัวอย่าง Response
{
"data": [
{
"id": "gpt-4.1-nano",
"provider": "OpenAI",
"name": "GPT-4.1 Nano",
"inputCostPer1M": 0.1,
"outputCostPer1M": 0.4,
"maxInputTokens": 1047576,
"maxOutputTokens": 32768,
"mode": "chat",
"supportsVision": true,
"supportsFunctionCalling": true
}
],
"meta": {
"total": 42,
"limit": 5,
"offset": 0,
"count": 5
}
}POST
/estimate
Estimate costs across models for a given usage pattern.
Request Body (JSON)
| Field | Type | Description |
|---|---|---|
| input_tokens | number* | Tokens per request (input) |
| output_tokens | number* | Tokens per request (output) |
| requests_per_day | number | Requests per day (default: 1) |
| model_id | string | Filter to specific model ID |
| provider | string | Filter by provider |
| max_results | number | Max results (default: 20, max 100) |
ตัวอย่าง Request
curl -X POST "https://tokentab.dev/api/v1/estimate" \
-H "Content-Type: application/json" \
-d '{
"input_tokens": 1000,
"output_tokens": 500,
"requests_per_day": 100
}'ตัวอย่าง Response
{
"data": [
{
"model_id": "deepseek-chat",
"model_name": "DeepSeek Chat",
"provider": "DeepSeek",
"cost_per_request": 0.000415,
"daily_cost": 0.04,
"monthly_cost": 1.25,
"input_cost_per_1m": 0.27,
"output_cost_per_1m": 0.56,
"max_input_tokens": 131072,
"max_output_tokens": 8192
}
],
"meta": {
"input_tokens": 1000,
"output_tokens": 500,
"requests_per_day": 100,
"total_models": 20
}
}Error Handling
Errors return a JSON object with error and message fields.
{
"error": "Rate limit exceeded",
"message": "You have exceeded the 100 requests/day limit for the free tier. Upgrade at https://tokentab.dev/api-pricing"
}| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Invalid request parameters |
| 404 | Model not found |
| 429 | Rate limit exceeded |
เริ่มต้นใช้งาน
JavaScript / TypeScript
const res = await fetch("https://tokentab.dev/api/v1/models?provider=anthropic");
const { data } = await res.json();
console.log(data); // Array of Anthropic models with pricingPython
import requests
resp = requests.get("https://tokentab.dev/api/v1/models", params={"provider": "anthropic"})
models = resp.json()["data"]
print(models) # List of Anthropic models with pricingcURL
# Get cheapest models with 128K+ context
curl "https://tokentab.dev/api/v1/models?min_context=128000&sort=inputCostPer1M&limit=10"
# Estimate costs for a chatbot
curl -X POST "https://tokentab.dev/api/v1/estimate" \
-H "Content-Type: application/json" \
-d '{"input_tokens": 2000, "output_tokens": 1000, "requests_per_day": 500}'