How to Reduce Claude API Token Consumption
If your Claude API bill is climbing faster than your usage feels like it should, the fix is almost always in how you structure prompts, manage conversation history, and shape outputs — not in finding a secret discount. Token consumption comes from three places: the system prompt and instructions you send every time, the conversation history you carry forward, and the length of the model's response. Reduce any one of these and your total token count drops immediately.
This article walks through concrete, testable changes you can make today, ordered roughly by impact: trimming input context, controlling output length, managing multi-turn conversations, picking the right model, and restructuring tool use. None of this requires rewriting your application — most of it is prompt and request-shape changes.
Audit What You're Actually Sending
Before optimizing, measure. Pull a handful of real requests from your logs and look at the breakdown between system prompt tokens, conversation history tokens, and completion tokens. Most teams find one of two patterns:
- A bloated system prompt repeated on every single call (style guides, few-shot examples, tool schemas) that dwarfs the actual user message.
- Unbounded conversation history where every prior turn, including early throwaway exchanges, gets resent on every follow-up.
If you're using SubToAPI, usage metadata is returned on every response, so you can track input vs. output tokens per request without building separate instrumentation — useful for spotting which conversations or endpoints are the real cost drivers before you start optimizing blind.
Trim the System Prompt
System prompts tend to accumulate: a style note here, an edge case there, until you have a 2,000-token instruction block for a task that needs 200. Go through yours and ask of each sentence: does removing this change model behavior on a real test case? If not, cut it.
Common offenders:
- Redundant examples. Three few-shot examples rarely outperform one well-chosen one. Test with one first.
- Restating the obvious. Claude doesn't need to be told "respond in a helpful and professional tone" if your actual instructions already imply that.
- Stale instructions. Rules added for a bug that no longer exists.
A smaller system prompt doesn't just save tokens on that request — it saves tokens on every request, multiplied by your call volume. This is the single highest-leverage change most teams can make.
Control Output Length Explicitly
Output tokens are usually more expensive than input tokens and are the easiest to overspend on because Claude will happily write a thorough, well-structured answer when a terse one would do.
Two levers:
- Set
max_tokensdeliberately. Don't leave it at a generous default "just in case." If your use case needs a one-line classification, cap it at something like 50–100 tokens, not 1,000. - Instruct format and length explicitly. "Answer in one sentence," "Return only valid JSON matching this schema, no explanation," or "Respond with a single word: yes, no, or unsure" all meaningfully cut completion length.
const response = await fetch("https://api.subtoapi.app/v1/messages", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "claude-sonnet-4",
max_tokens: 150,
system: "Classify the ticket. Respond with only a JSON object: {\"category\": string, \"priority\": \"low\"|\"medium\"|\"high\"}. No extra text.",
messages: [{ role: "user", content: ticketText }]
})
});
This kind of constrained-output prompt routinely cuts completion tokens by 70-90% compared to an open-ended "analyze this ticket" prompt. See /docs/messages for the full request format.
Manage Conversation History Deliberately
In multi-turn apps, history is the silent token killer. Every follow-up question resends the entire prior conversation unless you intervene. A few strategies:
- Summarize and compress. After a few turns, replace the full history with a short summary of what's been established, then continue from there. You lose some nuance but keep token growth linear instead of quadratic across a long session.
- Drop irrelevant turns. If a user asks three unrelated questions in one session, there's no reason turn three needs the full text of turn one.
- Cap history depth. Keep the last N turns plus a running summary, rather than the entire transcript, once a conversation passes a certain length.
- Use prompt caching for stable prefixes. If your system prompt and early context are identical across many requests, caching avoids reprocessing them — this is a distinct lever from the context-trimming discussed here and worth implementing separately once your prompts are already lean.
Match the Model to the Task
Not every call needs your most capable model. If you're running classification, extraction, or short-answer tasks, a smaller or faster model variant will often do the job with fewer output tokens and lower per-token cost — reserve the larger models for tasks that genuinely need deeper reasoning or longer context. Route by task type rather than defaulting everyone to the top-tier model for everything.
Restructure Tool Use Calls
If you're using tool/function calling, each tool definition you send counts toward input tokens on every call. Keep tool schemas minimal — short, clear parameter descriptions instead of verbose documentation — and only include the tools relevant to the current step rather than your entire tool catalog on every request. See /docs/tools for how tool definitions are structured.
Putting It Together
A realistic optimization sequence looks like:
- Measure current input/output token split per endpoint.
- Cut the system prompt to the minimum that preserves correct behavior.
- Set explicit
max_tokensand output-format instructions. - Add history summarization once conversations exceed 4-5 turns.
- Route simple tasks to smaller models.
- Trim tool schemas to only what's needed per call.
Each step compounds. Teams that do all six typically see total token volume drop by half or more without any change in output quality for the end user. If you want a quick way to validate these changes, run the same prompt through /docs/quickstart before and after trimming to compare token counts directly in the response metadata — pricing for the API layer itself is on /pricing if you're evaluating where token savings land relative to subscription cost.
Does a shorter prompt always mean a worse response?
Not necessarily. Many "thorough" instructions are redundant with what the model already infers from context. Test trimmed prompts against your real evaluation cases before assuming quality will drop — often it won't.
Should I cap max_tokens aggressively for every request type?
No — cap it based on expected output size for that specific task. A classification endpoint should have a tight cap; a long-form content generation endpoint needs headroom. Setting it too low truncates responses and can force costly retries.
Is summarizing conversation history worth the added complexity?
For short sessions, no — the overhead isn't justified. For long-running chat or support sessions, yes. Once history exceeds roughly 5-10 turns, the token cost of resending full context usually exceeds the cost of generating a summary.