Reduce Claude API Costs
LLM spend grows with users, context length, and generated output. These practices reduce the cost of each successful task without requiring a full product rewrite.
The fastest saving
Calculate your actual workload
Enter your real request volume and average token usage. The calculator compares the selected model at official rates and through Claude API Tech. Include retries and background calls in the request count.
Workload calculator
At official rates
$1,350.00
per month
Claude API Tech
$675.00
per month
Monthly saving
$675.00
Annual saving
$8,100.00
The estimate uses current prices for the selected model without prompt caching. Use it to understand the scale of your spend, not as a bill accurate to the cent.
Our pricing guide explains input, output, and cached tokens, how the total charge is formed, and how to calculate the cost of an individual request. How Claude API pricing works →
Collect seven days of usage first
A total invoice does not explain where the money went. Store usage next to the product feature that caused it, such as a support reply, processed document, agent step, or generated report. One week of data usually reveals which feature consumes the budget and why.
const startedAt = performance.now();
const message = await anthropic.messages.create({
model,
max_tokens,
messages
});
analytics.track("llm_request", {
feature: "support_reply",
model: message.model,
input_tokens: message.usage.input_tokens,
output_tokens: message.usage.output_tokens,
latency_ms: Math.round(performance.now() - startedAt)
});Find the largest source of spend
Do not rewrite every prompt at once. Rank product features by cost and start with the top result. Use the table below to choose the first experiment.
| What the data shows | Where spend grows | First thing to test |
|---|---|---|
| Large prompts in RAG or chat | input_tokens | Retrieval, history, prompt caching |
| Responses exceed what the UI needs | output_tokens | max_tokens and response format |
| Many calls per user action | retries or agent loop | Backoff, stop conditions, duplicates |
| One model handles every task | price of every token | Route simple work to a cheaper model |
What to optimize
1. Lower the price of the same tokens
Switching to Claude API Tech reduces Claude API costs by 50% without changing your models, prompts, or token volume. Create an account to get a compatible API key.
Reduce costs by 50% →2. Match the model to the task
Do not send classification, field extraction, and simple transformations to the most expensive model. Test quality on your own evaluation set and reserve stronger models for tasks where they produce a measurable improvement.
const model = task.requiresDeepReasoning
? "claude-sonnet-5"
: "claude-fable-5";
const response = await anthropic.messages.create({
model,
max_tokens: task.requiresLongAnswer ? 1200 : 300,
messages
});3. Remove unnecessary context
Avoid sending an entire conversation and every source document with each request. Keep the relevant passages, a compact summary of earlier messages, and the instructions required for the current step.
Unoptimized
- ●Full history
- ●Every document
- ●Repeated instructions
≈ 12,400 input tokens
Optimized
- ●Compact summary
- ●3 relevant passages
- ●Cached instructions
≈ 3,100 input tokens
4. Use prompt caching
Cache long system instructions and repeated context. Cached input reads cost 0.1× the standard input rate, which can reduce the cost of the repeated prompt portion by up to 90%.
const response = await anthropic.messages.create({
model: "claude-sonnet-5",
max_tokens: 500,
system: [{
type: "text",
text: policyAndInstructions,
cache_control: { type: "ephemeral" }
}],
messages: [{
role: "user",
content: relevantChunks.join("\n\n")
}]
});5. Limit generated output
Set a realistic max_tokens value and ask for the required response format. Streaming improves time to first token, but it does not reduce billable token usage by itself.
const stream = anthropic.messages.stream({
model: "claude-sonnet-5",
max_tokens: 300, // response ceiling
system: "Return only compact JSON with summary and risk_level fields. No Markdown.",
messages
});
for await (const event of stream) {
console.log(event);
}
const message = await stream.finalMessage();
console.log(message.usage.output_tokens); // tokens actually generated6. Prevent retry storms
Retry transient failures only and use exponential backoff. Do not repeat a successful model request because of a frontend error or a timeout in your own service.
Run one controlled test
Choose one expensive feature and run the same request set before and after the change. Compare cost, output quality, latency, and error rate. Move the next use case only when the result is acceptable.
- Record the current model, prompt, and average cost of a successful outcome.
- Save 30 to 100 representative requests without personal data.
- Change one variable: endpoint, model, context, caching, or output limit.
- Compare both versions against the same request set.
- Keep the change only when the saving does not damage product quality.
Next step
Compare model prices, then test one production use case against the new endpoint. Evaluate quality, latency, and actual cost before moving the rest of your traffic.