Calculate pricing
Calculate a deterministic token quote using the current rate card for one deployment.
Request
POST
/v1/pricing/calculateAuthentication: RequiredcURL
curl https://api.use-allm.com/v1/pricing/calculate \
-X POST \
-H "Authorization: Bearer $ALLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"deployment_id": "dep_openai_gpt_5_1_responses_global",
"usage": { "input_tokens": 1000000, "output_tokens": 100000 }
}'TypeScript
const quote = await allm.pricing.calculate({
deployment: "dep_openai_gpt_5_1_responses_global",
inputTokens: 1_000_000,
outputTokens: 100_000,
});
console.log(quote.totalUsd); // "2.250000"Python
quote = allm.pricing.calculate(
deployment="dep_openai_gpt_5_1_responses_global",
input_tokens=1_000_000,
output_tokens=100_000,
)
print(quote["data"]["total_usd"]) # 2.250000Request body
deployment_idstringrequired
Deployment whose current rate card should be applied.
usage.input_tokensinteger ≥ 0required
All input tokens, including the cached subset.
usage.output_tokensinteger ≥ 0required
Generated output tokens.
usage.cached_input_tokensinteger ≥ 0
Subset of input tokens charged at the cached rate.Default:
0Response
JSON · 200
{
"data": {
"deployment_id": "dep_openai_gpt_5_1_responses_global",
"currency": "USD",
"total_usd": "2.250000",
"line_items": [
{ "dimension": "input_tokens", "quantity": 1000000, "amount_usd": "1.250000" },
{ "dimension": "cached_input_tokens", "quantity": 0, "amount_usd": "0.000000" },
{ "dimension": "output_tokens", "quantity": 100000, "amount_usd": "1.000000" }
],
"rate_card": {
"currency": "USD",
"unit": "million_tokens",
"input_micro_usd": 1250000,
"cached_input_micro_usd": 125000,
"output_micro_usd": 10000000,
"source_url": "https://developers.openai.com/api/docs/models/gpt-5.1",
"observed_at": "2026-07-14T00:00:00Z"
}
}
}Cached tokens
cached_input_tokens must not exceed input_tokens. The response always includes three line items—even when one has a quantity and amount of zero—so downstream billing code can remain structurally stable.
Errors
| Status | Code | When it happens |
|---|---|---|
| 400 | INVALID_REQUEST | The body is invalid or contains negative or non-integer token counts. |
| 404 | DEPLOYMENT_NOT_FOUND | The deployment ID does not exist. |
| 422 | PRICING_UNAVAILABLE | No token rate card applies, or cached input exceeds total input. |
Response metadata
Every successful response includes
x-allm-catalog-release, x-request-id, and an ETag. Store the request ID in logs and the catalog release beside any persisted decision.