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_hereEndpoint
POST
https://www.calcis.dev/api/v1/estimateRequest body
JSON object with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The prompt text to estimate |
modelId | string | Yes | Target model ID (e.g. "claude-sonnet-4-6", "gpt-4o") |
systemPrompt | string | No | Optional 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"
}| Field | Description |
|---|---|
model | Model ID used for the estimate |
inputTokens | Counted input tokens (prompt + system) |
outputTokens | Predicted output tokens |
inputCost | Input cost in USD |
outputCost | Output cost in USD |
totalCost | Total estimated cost in USD |
confidence | "high" (regression model), "medium" (heuristic), or "low" |
currency | Always "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.010386Rate limits
60 requests per minute per API key. If you exceed this limit, the API returns 429 with a Retry-After header.
Error responses
| Status | Meaning |
|---|---|
400 | Bad request (missing fields, unknown model) |
401 | Missing, invalid, or revoked API key |
429 | Rate limit exceeded |
500 | Internal error |
Supported models
All models listed on the models page are supported. Pass the model ID as the modelId field.