Skip to main content
In short. A model remembers nothing between requests, so every request carries the whole context: the system prompt, documents and the full chat history. Send 50 requests with 150K tokens of context and you pay for the same 150K tokens 50 times. Three things cut the bill: caching (on Claude, GPT and DeepSeek repeated context is 10× cheaper or more), a smaller context, and a model whose price does not rise on long requests. Below are the numbers and concrete steps. All amounts use the RuAPI pricing page as of November 7, 2026, standard rate; your account may get a lower price. This article is for people who call the API themselves: bots, chats with long history, document analysis, agents. For Claude Code and Cline there is a separate guide — Saving on Claude Code and Cline.

Why long context is expensive

Request cost ≈ (input tokens × input price) + (output tokens × output price). The reply is usually short — hundreds or thousands of tokens. The input grows with every turn: the new question and the previous answer are added to the history, and all of it goes to the model again. Example: a chatbot with 100K tokens of documentation in the system prompt. A user asks 30 questions — that is 30 × 100K = 3M input tokens for the documentation alone, even if each question is one line. So on long context, the input is where to save first.

What one request costs

A request with 150K input tokens and a 2K-token reply. “With cache” means 140K tokens matched the previous request and were read from the cache, 10K are new. For Claude the new 10K tokens are priced as a cache write (1.25× regular input); for GPT and DeepSeek, as regular input. At 150K tokens claude-haiku-5-5 is already past its 100K threshold and billed at the higher tier (see the next section). Two takeaways. First, in this example the cache cuts the bill 4–5.5× on any of these models. Second, on long context the gap between models reaches 40×, which matters more than short tests suggest.

Where the price jumps after a threshold

Some models have tiered pricing: while the whole prompt is below the threshold the lower tier applies; above it, the whole request is billed at the higher tier, not just the tokens over the line. Cached tokens count toward the threshold too. Prices per 1M tokens, input / output: One price at any length: deepseek-flash, deepseek-v4-pro, claude-sonnet-5-5, claude-opus-5-5, glm-5.3, kimi-k3.1-pro, gemini-3.8-flash and gemini-2.5-flash-lite. The table shows examples. Every GPT-5.x and GPT-6 model except gpt-5.4-mini and gpt-5.4-nano (which have one price) has the 272K threshold, and gemini-2.5-pro has 200K; the full list with both tiers is on the pricing page. What it looks like in practice: double the context from 150K to 300K tokens, and an uncached request to deepseek-flash or claude-sonnet-5-5 costs about twice as much, while gpt-6-luna and gpt-5.4 cost almost 4× more: the context grew and the whole request moved to the higher tier. At 300K tokens deepseek-flash ($0.053 per request) is already cheaper than gpt-6-luna ($0.074).
If your requests hover around a threshold (say 90–110K tokens on Haiku), trim the history to stay below it or switch to a flat-priced model. The difference in the bill is several-fold.

Six ways to pay less

1. Turn on caching

On Claude, GPT and DeepSeek, context read from the cache is at least 10× cheaper than regular input. GPT and DeepSeek cache automatically. Claude caches through the native Anthropic API or through cache_control marks in the OpenAI-compatible format; RuAPI can also add the marks for you. To check that the cache hit: Console → Usage Logs → entry details → “Cache Tokens”. Details in Prompt caching.

2. Don’t change the start of the prompt

The cache only hits when the request matches the previous one from the very beginning, token for token. One change at the start and the whole long context is paid again at full price. Common causes:
  • the current date, time or a random ID in the system prompt;
  • a tool list that changes between requests (different order, a tool added or removed);
  • documents inserted in a different order each time;
  • a service note your app prepends to the history.
The rule is simple: everything constant goes first (instructions, tools, documents), everything that changes goes last. Only append new messages; don’t edit anything in the middle.

3. Compress old history

After 20–30 turns, replace the older part of the conversation with a short summary and keep the last few messages as they are. A cheap model such as deepseek-flash can write the summary. Do it rarely — once every few dozen turns, not on every turn: compressing changes the start of the prompt, so the cache is written once more.

4. Send what’s needed, not everything

If an answer needs one section of a large document or knowledge base, don’t send the whole thing. Split the text into chunks, find the relevant ones by meaning (text-embedding-3-small and text-embedding-3-large work with the same key) and send only those. A 5K-token request instead of 300K is dozens of times cheaper, and the model is less distracted.

5. Match the model to the context length

  • Long conversations, role-play, support, drafts — deepseek-flash: one price at any length, context up to 1M tokens.
  • Lowest price per token, simpler tasks — gemini-2.5-flash-lite: one price at any length, context up to 1M tokens.
  • Up to 272K tokens and you need GPT — gpt-6-luna, our cheapest GPT.
  • Short prompts and it has to be Claude — claude-haiku-5-5, while the prompt stays under 100K tokens.
  • Careful analysis of a long document where accuracy matters — claude-sonnet-5-5 with caching: the price doesn’t rise on long requests, and the cache removes most of the bill.
Quality and cost on a real workload are compared in DeepSeek vs Claude.

6. Ask questions in a batch

If you have several questions about the same long document, send them back to back without pauses: by default, Claude’s cache lives 5 minutes after the last request, and after a break the long context is paid in full again. If the questions are known in advance, ask them in one request and get the answers as a list — the long document goes to the model only once.

FAQ

Along with your word the model received the whole chat history and the system prompt — it doesn’t keep them between requests. Usage Logs show how many input tokens there were. The longer the history, the more each next question costs.
Yes. The threshold is measured on the whole prompt: both regular and cached tokens. If the prompt is longer than the threshold, the whole request, cache included, is billed at the higher tier.
Per token, gemini-2.5-flash-lite: up to 1M tokens of context and one price at any length. If you need a stronger model, take deepseek-flash — also 1M tokens and one price. If you have several questions about the document, ask them back to back so the repeated context is read from the cache.
Both. The cache makes repeated context cheap, but you still pay for it on every turn, and a long context easily crosses a pricing threshold. Compressing once every few dozen turns shrinks the context itself. Just don’t compress on every turn, or the cache will never hit.
Open Usage Logs → entry details. If repeated requests show an empty or tiny “Cache Tokens” line, the start of the prompt changes between requests (see way 2), or more than 5 minutes passed between requests (for Claude, by default).

Next

Prompt caching

How caching works for Claude, GPT and DeepSeek and how to check a hit.

Saving on Claude Code and Cline

The same for coding agents: cache, /compact, model choice.

DeepSeek vs Claude

The same working day priced on different models.

Pricing

All models, tiers and cache prices.