Docs menu

Docs / Concepts

Request cost

Every successful response carries the amount charged in usage.cost, in USD.

Last updated


Your setup

Fills in YOUR_API_KEY in the code on this page. The key stays in this tab: it is never sent and never saved.

Where the cost appears

Cent AI adds one field to the standard usage object: cost, the amount charged for the request in USD, as a decimal string with 9 fraction digits (for example "0.000363000"). It equals the charge recorded in your balance history, after the minimum and rounding.

EndpointWithout streamingWith streaming
POST /v1/chat/completionsusage.cost in the bodyusage.cost in the final usage chunk (choices: []), sent only when you set stream_options.include_usage: true
POST /v1/messagesusage.cost in the bodyusage.cost in the last message_delta event
POST /v1/responsesusage.cost in the response objectusage.cost in the response object of response.completed

There is no cost header.

Streaming with OpenAI clients

Ask for usage in the stream to receive the cost:

curl https://api.cent-ai.dev/v1/chat/completions \
  -H "Authorization: Bearer $CENT_AI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"glm-5.3","messages":[{"role":"user","content":"Hello"}],
       "stream":true,"stream_options":{"include_usage":true}}'

The last data chunk before data: [DONE] then carries the usage:

data: {"id":"chatcmpl-9f2c1a","object":"chat.completion.chunk","created":1792051200,"model":"glm-5.3","choices":[],"usage":{"prompt_tokens":10000,"prompt_tokens_details":{"cached_tokens":9000},"completion_tokens":800,"total_tokens":10800,"cost":"0.000363000"}}

Reading it from an SDK

SDKs keep fields they do not know. With the OpenAI Python SDK:

from openai import OpenAI

client = OpenAI(base_url="https://api.cent-ai.dev/v1", api_key="YOUR_API_KEY")
r = client.chat.completions.create(model="glm-5.3", messages=[{"role": "user", "content": "Hello"}])
print(r.usage.cost)

Estimated usage

If the model does not report usage, Cent AI counts tokens with a tokenizer and marks the response with usage.estimated: true. Estimated usage never contains cache tokens. The request is marked estimated on the Requests page too.

When there is no cost in the response

If a stream breaks before the usage arrives, your client does not receive cost. The charge is still recorded and shows on the Requests page, matched by the x-request-id header.