API Reference

Integrate LLM cost estimation into your tools, pipelines, and IDE extensions. One endpoint, clean JSON, predictable pricing.

Authentication

All API requests require a Bearer token in the Authorization header. Create API keys from your dashboard. API access requires Pro tier or above.

Authorization: Bearer calc_your_api_key_here

Endpoint

POSThttps://www.calcis.dev/api/v1/estimate

Request body

JSON object with the following fields:

FieldTypeRequiredDescription
textstringYesThe prompt text to estimate
modelIdstringYesTarget model ID (e.g. "claude-sonnet-4-6", "gpt-4o")
systemPromptstringNoOptional system prompt (counted as input tokens)

Response

{
  "model": "claude-sonnet-4-6",
  "inputTokens": 847,
  "outputTokens": 523,
  "inputCost": 0.002541,
  "outputCost": 0.007845,
  "totalCost": 0.010386,
  "confidence": "high",
  "currency": "USD"
}
FieldDescription
modelModel ID used for the estimate
inputTokensCounted input tokens (prompt + system)
outputTokensPredicted output tokens
inputCostInput cost in USD
outputCostOutput cost in USD
totalCostTotal estimated cost in USD
confidence"high" (regression model), "medium" (heuristic), or "low"
currencyAlways "USD"

Examples

curl

curl -X POST https://www.calcis.dev/api/v1/estimate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer calc_your_api_key_here" \
  -d '{
    "text": "Explain how transformer attention works",
    "modelId": "claude-sonnet-4-6"
  }'

JavaScript / Node.js

const response = await fetch(
  "https://www.calcis.dev/api/v1/estimate",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "Authorization": "Bearer calc_your_api_key_here",
    },
    body: JSON.stringify({
      text: "Explain how transformer attention works",
      modelId: "claude-sonnet-4-6",
    }),
  }
);

const estimate = await response.json();
console.log(estimate.totalCost); // 0.010386

Rate limits

60 requests per minute per API key. If you exceed this limit, the API returns 429 with a Retry-After header.

Error responses

StatusMeaning
400Bad request (missing fields, unknown model)
401Missing, invalid, or revoked API key
429Rate limit exceeded
500Internal error

Supported models

All models listed on the models page are supported. Pass the model ID as the modelId field.