- know what a request costs, from the catalog and from
usage - match the model to each step of your app
- control reasoning and output tokens
- get more cache hits
- keep conversations and images from growing the bill
- track spend and set a ceiling
Know what a request costs
Every inference request is billed per token, at the rates in the model catalog (GET /platform/v2/models):
- Input tokens are everything you send: instructions, conversation history, documents and images. They bill at
pricing.input. - Output tokens are everything the model writes, including any reasoning, whether or not you see it. They bill at
pricing.output, which is usually several times the input rate. - Cached tokens bill at
pricing.cache_read, and on some models writing the cache bills atpricing.cache_write. See Prompt Caching.
usage. Estimate each request’s cost from it, and log the result next to the model and the feature that made the call:
cache_write_tokens in the same details object), and the higher pricing.long_context rates some models charge once a prompt passes min_prompt_tokens, so treat it as an estimate. Read the Cache Fields in usage shows every field by endpoint, and your Usage page in Studio is the record of what you were charged.
Match the model to each step
Rates differ widely across the catalog, and the most capable model is rarely needed for every step. As of November 2026, Claude Sonnet 5.5 lists $2 per million input tokens and $10 per million output tokens, while GPT-6 Luna lists $0.10 and $0.50.- Split your app into steps (classify, extract, draft, check) and choose a model per step. Short classifications, routing decisions and extractions often run well on small, fast models; long reasoning and careful writing may need a larger one.
- Test the cheaper model first on your own examples, and move up only where quality falls short. See Testing, Evaluation and Observability.
- Pin the model you chose. A pinned
modelis billed at that model’s catalog rate on every call, rather than a rate that changes per request. On guarded Completions,model_familyand auto-routing can pick a different model, at a different price, per request. - Watch for replacements. Pinning isn’t a price guarantee: when a model you use is deprecated, its requests can be redirected to a replacement priced differently, and
deprecation_notestates any increase. Check catalog rates on a schedule, log theX-Gloo-Model-Redirected-Fromheader, and follow Model Updates. See Choosing, Pinning and Updating Models.
Control reasoning and output tokens
Output tokens cost the most, and on reasoning models much of the output is thinking.- Know which models think unprompted. A model with
reasoning.thinks_by_default: truereasons, and bills that reasoning, even when you send no reasoning setting. - Lower the effort, not the limit. The reasoning effort is the main control over how long a model thinks. Use
low, ornoneon a model whoseeffort_levelsinclude it, for short tasks. Loweringmax_output_tokens(ormax_tokens) doesn’t make the model think less; it cuts the answer off when thinking uses the limit. - The limit is a ceiling, not a charge. You pay for the output tokens the model uses, not for the limit you set. Size the limit so answers aren’t cut off, then let effort set the cost. See Size the limit.
- Read where output went. Where the model reports it,
usage.output_tokens_details.reasoning_tokens(Responses) orusage.completion_tokens_details.reasoning_tokens(Chat Completions) is the part of the output that was reasoning. Claude models report it as0or leave it out on some endpoints, and their reasoning is still in the output count. - Ask for shorter answers. “Answer in two sentences” or a tight output schema cuts output tokens on every model.
Get more cache hits
Prompt caching bills the repeated start of a prompt at the much lowercache_read rate, usually around a tenth of the input rate. It only works when the start of the prompt is identical to a recent request, token for token.
- Put stable content first. Order each request from most stable to least: instructions, reference documents, tool definitions, conversation history, then the new question. Keep timestamps, user names and per-request snippets at the end.
- Keep the prefix byte-identical. Build it from the same template every time; don’t reorder examples, tools or JSON keys between requests.
- Turn on caching where it’s opt-in. Claude models cache when you send the
X-Cache-TTLheader (5mor1h); on Anthropic Messages usecache_control. OpenAI, DeepSeek, Gemini and most other models cache automatically above a minimum prompt length. - Use a stable
prompt_cache_keyon OpenAI models, named after the prompt it caches, such as"support-assistant-v3", and change it when the instructions change. Per-request keys defeat the cache. - Check that it works. Log the cached-token count from
usagewith every request. A hit rate that drops to zero usually means something started changing the prefix. Expect fewer hits for a while after a provider failover, since each provider holds its own cache.
Keep conversations and images in check
Your app sends the whole conversation on every request, so every turn bills all the turns before it again. A 30-turn conversation sends all 30 turns on turn 31.- Trim or summarise long histories. Keep the instructions and the recent turns; drop or summarise the oldest. See Conversations and Context Windows.
- Append, don’t rewrite. Adding new turns to the end keeps the earlier conversation as a cacheable prefix.
- Mind images. An image is billed as input tokens at the model’s input rate, and again on every turn it stays in the history. Scale images down before you send them, and describe an image once and keep the text when the conversation moves on. See Images in Conversations.
- Send only the context the question needs. Retrieving the three most relevant passages costs less than pasting a whole document, and often answers better.
Track spend and set a ceiling
- Watch the Usage page. API Usage in Gloo AI Studio shows spend, requests and tokens (input, output and cache) over time. Filter by API key to see which application is spending, so give each application and environment its own API key.
- Log
usageper feature. Studio shows totals; your own logs tell you which feature or customer drove them. Record the model, the token counts and your cost estimate with every request. - Know your ceiling. Organizations on prepaid credits have a monthly API spend limit, $4,000 per calendar month (UTC) unless Gloo has set a different one. When it’s reached, requests return
429withMONTHLY_SPEND_LIMIT_REACHEDuntil the month resets. Contact support to raise or lower it, including lowering it as a safety net for a new app. - Cap your own loops. Retries, tool loops and agents can multiply requests. Bound them with a retry budget and a step limit. See Error Handling and Retries and Tools, Structured Output and Agents.
Summary
- Output costs more than input, and reasoning is output: control it with effort, not by shrinking the limit.
- Pick the smallest model that passes your tests for each step, and pin it.
- Put stable content first, turn on caching where it’s opt-in, and check the cached-token count.
- Trim long conversations and shrink images, since every turn resends them.
- Log
usageper feature, filter Studio usage by API key, and know your monthly spend limit.
Next steps
Cost and Speed
The lesson: how a request is priced, caching and reasoning effort.
Prompt Caching tutorial
Restructure a prompt for caching and measure the savings.
Reasoning Models in Production
Effort, output limits, streaming and cut-off answers.
API Usage
Spend, requests and tokens in Studio.

