API Docs

v1

Query ราคา LLM และประเมินต้นทุนผ่าน API ฟรี ไม่ต้องสมัคร

Base URL

https://tokentab.dev/api/v1

Authentication

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
Developer1,000$19/mo
Pro10,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

ParameterTypeDescription
qstringSearch by model name or ID
providerstringFilter by provider name (e.g. OpenAI)
max_input_costnumberMax input cost per 1M tokens
min_contextnumberMin context window (tokens)
visionbooleanFilter vision-capable models
function_callingbooleanFilter function-calling models
sortstringSort field (default: inputCostPer1M)
orderstringasc or desc (default: asc)
limitnumberResults per page (max 500, default 100)
offsetnumberPagination 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)

FieldTypeDescription
input_tokensnumber*Tokens per request (input)
output_tokensnumber*Tokens per request (output)
requests_per_daynumberRequests per day (default: 1)
model_idstringFilter to specific model ID
providerstringFilter by provider
max_resultsnumberMax 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"
}
StatusMeaning
200Success
400Invalid request parameters
404Model not found
429Rate 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 pricing

Python

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 pricing

cURL

# 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}'