Build with the API
How API calls are charged
You pay for what a call delivered, never more than the prices on the pricing page, the same for conversations in the app and for the API.
What each call is billed by#
| Call | Billed by |
|---|---|
| Chat completions and messages | Input and output tokens, each at its own price per million. |
| Embeddings | Input tokens. |
| Images | Each image delivered. |
| Speech to text | The length of audio transcribed, at a price per second. The page lists it per minute. |
| Web search | Each search. A search that fails is not charged. |
The counts are the ones the model reported for the call. Chat, messages, embeddings and speech to text answers carry them in usage, and Logs itemises them for every kind of call.
Often less than the listed price#
A listed price is the most a call costs. Most models are charged what the call cost to serve plus a fixed share, never more than the listed price, and that is usually much less: input the model has just read, such as the earlier turns of a conversation or a long instruction sent with every call, is reused rather than processed again and costs a fraction of new input. A conversation that goes back and forth over the same material, as sven's does, is charged far less than its token counts at the listed price. Each request's actual charge is in Logs.
Credit is checked before a call runs#
Before a call starts, the most it could cost is set aside from your credit. When what is left (of your credit, the key's spending limit or the account's monthly budget, set under Billing) is less than that, what is left is set aside instead and the call runs: you are never charged more than was set aside, so the last of your credit can always be spent. Only a call with nothing left to set aside is refused with 402, before anything runs. See Errors.
When the call finishes you are charged for what it actually used, never more than the amount set aside, and the rest is available again. For chat, the most it could cost is set by the length of your input and the output you allow with max_tokens (4096 tokens when you set none), so a smaller max_tokens needs less credit on hand.
If a call fails#
A call that fails before it delivers a result is not charged. A streamed reply that breaks partway is charged only for the usage the model had already reported, and what it delivered is kept: send the same request again with the same Idempotency-Key and you get that output again, ending with the same error, without paying again. If your connection drops while a streamed reply is being written, the reply still finishes and you are charged for what it produced. Send the same request again with the same Idempotency-Key to receive it without paying again. See Streaming and Safe retries.
Data retention and price#
A model has one id, whatever it costs and wherever it runs. By default a call is served, and charged for, only by providers that keep no data. Once the person a key acts for allows sharing data with a model under Settings, Models, and their organisation lets them, the model's version that may keep data serves their calls where it is offered, at its own price, which can differ from the version that keeps none. A model offered only where data may be kept is refused with 403 until it is allowed. The model list shows which models keep no data (zero_data_retention), which must be allowed first (needs_data_sharing) and what each costs, and every call is charged by the price of the model that served it, never more. See Models and data.
See what you were charged#
- Usage totals charges by function, model and where they came from, such as an API key or the chat.
- Logs shows each request with its cost, or "Not charged" when it was not, and exports it as CSV. An export holds at most 100,000 requests, so narrow the filters for more.
- Billing shows the balance, the monthly budget and the latest credit added, spent and returned. Each request's charge is in Logs.
Prices are not copied here#
Prices live on the pricing page and, for models, in the pricing field of the model list. Both are read from the price list every call is charged by. A figure written anywhere else could only go stale.