Estimating costs and cache pricing
The cost of a text call is the sum of four Token types, each priced separately: Input (cache miss) at the price table's Input price, Input (cache hit) and Output at the prices of the same name, and Explicit cache write at the Explicit cache creation price. The prices are the "Platform price" in the model's details in the workspace's Model marketplace; long-context tiers, time-based pricing, service tiers and other conditions change which price applies. Only successful calls are charged, and you can check an estimate against Cost in the request logs and "Consumption" under Subscription & Credits.
The four billed Token types
"Token usage" in the log detail splits a call's Tokens into four types that do not overlap:
| Name in the logs | Meaning | Matching column in the price table |
|---|---|---|
| Input (cache miss) | The part of this call's input that missed the upstream prompt cache and had to be processed again | "Input" |
| Input (cache hit) | Input served from the upstream prompt cache | "Input (cache hit)"; "Input" when it has no separate price |
| Output | Tokens generated by the model, including thinking (reasoning) | "Output" |
| Explicit cache write | Input written to the upstream cache through cache_control; appears only with Anthropic-protocol upstreams |
"Explicit cache creation"; "Input" when it has no separate price |
- Split the input: Input (cache miss) plus Input (cache hit) is the call's whole input.
prompt_tokensin OpenAI-compatible responses usually already includes the cache hits, so when estimating, subtract the hits first and multiply each part by its own price; do not charge the hits again at the input price. - The two totals differ: "Total" in "Token usage" is the sum of the four types; "Total tokens" in the log list and in the detail is input plus output and excludes Explicit cache write, so it can be smaller than "Total".
- Viewing them in the list: by default the log list shows only "Total tokens". Turn on "Input (cache miss)", "Input (cache hit)", "Output" and "Cost" under Columns; Explicit cache write is shown only in the detail.
Figure 1: Token usage in the log detail lists the count and share of the four types, and Cost in the basic information is what this call was actually charged. Demonstration data; click the image for full size.
Estimating the cost of a call
- In the workspace's Model marketplace, open the model, go to "Providers & pricing" and find the source you plan to use. For platform channels, read the "Platform price"; "BYOK reference price" and "Official reference price" are for comparison only and are not what the platform charges.
- Check the price unit. Text models are usually priced "/ 1M Tokens"; image, video and audio may be priced per "image", "second", "minute", "10K characters" or "request".
- Use the "Conditions" column to find the row this call falls under, then calculate:
Cost = Input (cache miss) × input price
+ Input (cache hit) × Input (cache hit) price
+ Output × output price
+ Explicit cache write × Explicit cache creation price
(For prices per 1M Tokens, divide each Token count by 1,000,000 first)
If you have permission to see discounts, the price table shows the struck-through original price next to the discounted price; estimate with the discounted price. A "—" in the price table means no price is available yet, not that it is free.
Figure 2: Providers & pricing in the model details lists the platform price, pricing method and conditions for each source. Demonstration data; click the image for full size.
Pricing conditions in the price table
The price table title shows the pricing method, and the "Conditions" column shows where each row's prices apply:
| Pricing method or condition | Effect on cost |
|---|---|
| Fixed rate | Every call uses the same set of prices |
| Token-length pricing | The tier is chosen by the Token length of a single request, and the whole request is charged at that tier's prices. Input length counts all input Tokens, including cache hits, so a long-context request is charged at the long-context tier however high its cache hit rate is |
| Time-based pricing | A multiplier is applied according to the weekday and time slot of the request. Slots include the start and exclude the end, in the time zone shown in the price table; only the day of the week counts, not public holidays or make-up workdays |
| Conditional pricing | The price depends on conditions such as service tier, modality, resolution and duration. For example, "Service tier" is priced by the tier the upstream actually used, and "First N … free per request" means that quantity is deducted from each call before charging |
| Complex pricing | The page shows "Some pricing conditions cannot be fully displayed. Check the complete rules before use."; contact support to confirm before estimating |
Which calls are charged
- Only successful calls are charged: calls where the upstream returns an error or the connection fails are free. When the gateway switches channels or falls back to another model, only the final successful attempt is charged, and the cost of failed attempts is not passed on to you; see Retries and fallback.
- BYOK calls: you settle Token costs directly with the provider. For each successful call the platform charges a platform service fee set by your subscription edition, and Cost in the logs shows this fee; see BYOK fees and credentials. Coding Plans connected through BYOK are billed by the provider's plan, not by per-Token prices; see API services and Coding Plans.
- Async tasks: video and other async generation is settled when the task completes. The request that creates the task costs nothing itself, and the log list shows "Settling" until settlement; see Multimodal capabilities.
Explicit cache pricing
When a request marks cache breakpoints with cache_control and the call is served by an Anthropic-protocol upstream, the part written to the cache is recorded as Explicit cache write and charged at the "Explicit cache creation" price; Anthropic's cache write price is higher than normal input. Requests with the same prefix sent within the next few minutes record that part as Input (cache hit), charged at the "Input (cache hit)" price. When a prefix is reused again and again, the extra write cost is usually recovered after one or two hits.
When the upstream uses the OpenAI-compatible protocol, the gateway removes cache_control from the request before sending it. Only the upstream's automatic implicit caching applies then, and no Explicit cache write occurs. Marking rules and ways to raise the hit rate are covered in Reducing costs and improving cache reuse.
Checking with logs and Consumption
- Cost in the logs: the Credits actually charged for this call, converted to CNY. It is calculated at call time with the prices then in effect and fixed from then on, so later price changes do not alter amounts in historical logs. "Not calculated" means the call produced no charge, for example because it failed; "No permission to view" means the current account cannot see this log's cost.
- Consumption: the current Account Owner sees "Credits consumed" per request under "Consumption" in Subscription & Credits. Its "Request ID" is the same as the Request ID at the top of the log detail, so the two can be matched entry by entry. A single query cannot span more than 90 days, and calls that just finished may take a few minutes to appear.
For amounts that do not match, see Unexpected costs and cache misses; the rules for Credits and subscriptions are in Billing and Credits.
Figure 3: Consumption lists the time, API key, workspace, model and Credits consumed for each request, and can be matched with the logs by Request ID. Demonstration data; click the image for full size.


