Skip to content
TutujinAPI

How to control LLM API costs: 10 things you can do today

LLM API spend comes down to unit price, input length, output length and call volume. Ten measures roughly in order of impact — choosing the right model tier, tiered routing, context caching, capping output and per-key spending limits — with savings shown at live prices.

LLM API spend = number of calls × (input tokens × input price + output tokens × output price). Only three things move: the unit price, the tokens per call and the number of calls. The ten measures below are roughly ordered by impact. The first two — the right model and tiered routing — usually save the most, then controlling input, then controlling output.

1. Pick the right model tier

ModelVendorCheapest groupInput ¥/1MOutput ¥/1MPer request ¥
gpt-5.5OpenAIStandard¥10¥80—
gpt-5.4-miniOpenAIStandard¥1.5¥9—
gpt-4o-miniOpenAIStandard¥0.3¥1.2—

Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

A vendor's flagship and its small model can differ in price by tens of times. Run your evaluation on the small model first and move up only if accuracy falls short. How to evaluate: How to choose a model.

2. Tiered routing: only hard questions go to the big model

Let a cheap model judge the type or difficulty of each request, answer the easy ones directly, and pass only the hard minority to a big model. Say you have 100,000 requests a month with 2,000 input and 400 output tokens each.

Everything on the flagship:

Cost estimate · gpt-5.5 (Standard)

Unit price
input ¥10 / output ¥80 (per 1M tokens)
Usage per request
2,000 input tokens, 400 output tokens
Requests
100,000
Cost per request
¥0.052

Total about ¥5,200Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

80% routed to a small model:

Cost estimate · gpt-5.4-mini (Standard)

Unit price
input ¥1.5 / output ¥9 (per 1M tokens)
Usage per request
2,000 input tokens, 400 output tokens
Requests
80,000
Cost per request
¥0.0066

Total about ¥528Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

The remaining 20% on the flagship:

Cost estimate · gpt-5.5 (Standard)

Unit price
input ¥10 / output ¥80 (per 1M tokens)
Usage per request
2,000 input tokens, 400 output tokens
Requests
20,000
Cost per request
¥0.052

Total about ¥1,040Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

Add the last two for the routed total. The routing step costs a little too, so use the cheapest model and have it output just a label.

3. Trim the prompt

The system prompt is sent with every request. Cut repeated instructions, surplus examples and pleasantries; a few hundred tokens saved, times hundreds of thousands of calls a month, adds up.

4. Cap the output

  • Set max_tokens, or max_completion_tokens on reasoning models.
  • Spell out format and length in the prompt, such as "output JSON only" or "under 80 words".
  • On reasoning models, reasoning_effort can lower the thinking effort where supported.

Output usually costs several times as much as input. With 100,000 calls a month and 2,000 input tokens each, 800-token answers:

Cost estimate · deepseek-v4.1-flash (China Models)

Unit price
input ¥2.8 / output ¥11.2 (per 1M tokens)
Usage per request
2,000 input tokens, 800 output tokens
Requests
100,000
Cost per request
¥0.0146

Total about ¥1,456Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

Answers cut to 300 tokens:

Cost estimate · deepseek-v4.1-flash (China Models)

Unit price
input ¥2.8 / output ¥11.2 (per 1M tokens)
Usage per request
2,000 input tokens, 300 output tokens
Requests
100,000
Cost per request
¥0.00896

Total about ¥896Prices in CNY, cheapest group for each model; updated Nov 13, 2026, 6:13 PM.

5. Use context caching

Put the unchanging system prompt and documents first; on models with caching, hits are billed at the cache-read price, usually far below normal input. Details and savings: What context caching is and how it saves money.

6. Trim the chat history

Multi-turn chats resend the history every time, so by turn 20 a request's input can be more than ten times that of turn 1. Keep only the last few turns and have a small model summarize the rest.

7. Pick a group with the right price

The same model costs different amounts in different groups. Use the lowest-price group for development and for batch work that can be retried, and official or cloud groups for production — see How to choose a group.

8. Put many items in one request

When processing lots of short texts, such as classifying product titles, send about 20 per request and ask for a JSON array in the same order. The system prompt goes out once instead of 20 times. Do not overload a request — models start skipping items — and check the count when results come back.

Python
import json
import os
from openai import OpenAI

client = OpenAI(base_url="https://www.tutujin.com/v1", api_key=os.environ["TUTUJIN_API_KEY"])

titles = ["Men's cotton T-shirt", "Stainless steel bottle 500ml", "Kids' non-slip sneakers"]  # about 20 per batch in practice

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[
        {"role": "system", "content": "Assign each product title one category: apparel, home, footwear, other. Output a JSON array in input order and nothing else."},
        {"role": "user", "content": json.dumps(titles)},
    ],
)
labels = json.loads(resp.choices[0].message.content)
assert len(labels) == len(titles), "count mismatch, rerun this batch"

9. Give every key a spending limit and a model allowlist

An infinite loop or a leaked key can generate a flood of calls in minutes. Give each key a spending limit and an expiry date, and use the model allowlist so it can only call the models your product needs — nobody can use it to call an expensive model. More in API key security best practices.

10. Review usage regularly

Once a week, open Usage in the console, look at spend by model and by key, find the calls that cost the most and optimize those first. Watch especially closely in the first days after a feature launch.

Summary

MeasureWhat it cutsEffort
Right model tierUnit priceChange the model parameter after an evaluation
Tiered routingUnit priceAdd a routing step
Trim the promptInput tokensEdit the prompt
Cap the outputOutput tokensAdd a parameter, edit the prompt
Context cachingInput priceReorder the prompt
Trim chat historyInput tokensChange conversation handling
Right groupUnit priceUse another key
Several items per requestInput tokensChange how you call
Limits and allowlistsAccidental spendConsole settings
Review usageFinds what to fixA weekly look

Billing rules: How LLM API pricing works.

FAQ

Which measure saves the most?

Usually choosing the right model tier. Unit prices can differ by tens of times between tiers; test a cheap model first and move up only if it falls short. This one tends to have the biggest effect.

Does capping max_tokens hurt answer quality?

Set it too low and answers get cut off, with finish_reason set to length. Leave headroom for the length you actually need and ask for concise answers in the prompt.

How do I stop a leaked key or a buggy loop from running up a big bill?

Give every key a spending limit and an expiry date, and turn on the IP allowlist and model allowlist. If something goes wrong, the damage stays within one key's limit.

Is there a monthly plan or fee?

No monthly fee; you pay for what you use. For company purchasing or bank transfer, contact WeChat support at JsnonoChat.