Request cost
GET https://api.entrim.ai/v1/generation?id={x-request-id}
Returns the exact amount billed for one request. It is most useful for a stream that ended before its usage block arrived, for example when the user stopped the generation.
Get the request ID
Every response carries an x-request-id header. It is sent before the first token, so you have it even if the stream is cut off at once. Keep it with the request.
Example request
curl "https://api.entrim.ai/v1/generation?id=$REQUEST_ID" \
-H "Authorization: Bearer $ENTRIM_API_KEY"
Use any active Model API key of the account that made the request. A request appears about a minute after it ends.
Example response
{
"data": {
"id": "0f6f3c1e8a7d4b52a9c1d2e3f4a5b6c7",
"model": "zai-org/GLM-5.3-Flash",
"created_at": "2026-11-09T14:00:00.000Z",
"status": "success",
"tokens_prompt": 1205,
"tokens_completion": 100,
"tokens_cached": 200,
"tokens_cache_write": 5,
"total_cost": "0.000398",
"cost_details": {
"input": "0.0003",
"cache_read": "0.000006",
"cache_write": "0.000002",
"output": "0.00009"
}
}
}
Response fields
| Field | Type | Description |
|---|---|---|
id | string | The request ID you asked for |
model | string | The model that was billed |
created_at | string | When the request started, in UTC |
status | string | success or failure |
tokens_prompt | integer | All input tokens, including cached ones |
tokens_completion | integer | Output tokens, including reasoning |
tokens_cached | integer | Input tokens read from the cache |
tokens_cache_write | integer | Input tokens written to the cache |
total_cost | string | The amount billed, in USD |
cost_details | object or null | The amount by kind of token, in USD. input covers only the input tokens not read from or written to the cache. The four parts add up to total_cost exactly. It is null in the rare case the split cannot be shown; total_cost is still exact |
Amounts are strings so that no digits are lost. Parse them with a decimal type, not a float.
Streams that were cut off
If output was generated before the connection dropped, you are billed for that output and for the prompt. The model never reports usage for such a stream, so we count the tokens ourselves and bill the whole prompt at the input rate, with no cached tokens.
If no output was generated, the request is not billed and the lookup returns 404.
Errors
| Status | Code | Meaning |
|---|---|---|
400 | invalid_id | The id parameter is missing or too long |
401 | missing_api_key, invalid_api_key | The key is missing, revoked or not a Model API key |
404 | not_found | No billed request of your account has this ID. It may still be on its way, so try again after a minute. If it is still missing after that, the request was not charged |
409 | ambiguous_id | Your account used this ID on more than one request |
429 | rate_limited | More than 1,200 lookups in a minute with this key. Wait for retry_after_seconds |
Requests can be looked up for 90 days.