EN ▾
Get API key

Commercial API for LLM Cost: A Budgeting Method

Budgeting a commercial API for LLM cost comes down to three numbers: tokens in, tokens out, and how often you call. Here is the method, with the arithmetic done at this site's actual rates.

Updated

A balance scale weighing token cubes against coins, illustrating LLM API cost budgeting

Key points

The formula

Every request has one cost: (input tokens x input rate) + (output tokens x output rate). At this site the input rate is $0.15 per 1,000,000 tokens and the output rate is $0.50 per 1,000,000 tokens. Both are billed on actual usage, which the API reports at the end of each response, and failed or refused requests are not charged.

That is the entire pricing model. There is no seat fee, no monthly minimum and no tier you outgrow. You buy credit, calls draw it down, and the credit stays until you use it. The model behind it is one open-weight model, run by an independent provider and reached with the model ID uncensored through an OpenAI-compatible endpoint. If you are comparing providers, check their current pricing pages for their numbers, since rates and billing units change.

To budget, you only need to estimate four things: tokens per request in, tokens per request out, requests per day, and days. Everything else is multiplication.

Worked examples at the real rates

Four common shapes, computed exactly.

WorkloadInputOutputCost
One short Q&A call2,000 tokens = $0.0003500 tokens = $0.00025$0.00055
1,000 short Q&A calls2,000,000 tokens = $0.30500,000 tokens = $0.25$0.55
One long-document call80,000 tokens = $0.0122,000 tokens = $0.001$0.013
100 long-document calls8,000,000 tokens = $1.20200,000 tokens = $0.10$1.30

The long-document row shows why input matters: the prompt is 40 times bigger than the answer, and it is still the cheaper side per token, so the call stays around a cent. The context window is 100,000 tokens, prompt and completion together, so 80,000 in leaves room for a long reply.

A chat product with 1,000 conversations per day, each averaging 3,000 input tokens and 600 output tokens, costs per day: input 3,000,000 tokens x $0.15 / 1M = $0.45, output 600,000 tokens x $0.50 / 1M = $0.30, total $0.75. Over 30 days that is $22.50. Double the traffic and you double the number; the relationship stays linear.

Why history makes input the main cost

Chat completions are stateless. To keep a conversation going you send the earlier messages again with every turn. A 10-turn chat where each turn adds about 500 tokens does not use 5,000 input tokens in total, it uses 500 + 1,000 + 1,500 and so on, which sums to 27,500 for ten calls. The last call alone carries 5,000.

Agent loops behave the same way and grow faster, because tool results get appended too. Take an agent that makes 10 calls with input sizes rising from 5,000 to 50,000 tokens in steps of 5,000, each producing about 400 output tokens. Input totals 275,000 tokens, which is $0.04125. Output totals 4,000 tokens, which is $0.002. One run costs $0.04325, so 1,000 runs cost $43.25. The output side was under 5% of the bill.

The practical lessons follow directly:

  • Trim history. Summarize turns older than the last few and keep the summary short.
  • Keep system prompts tight; they are paid for on every call.
  • Do not cut max_tokens to save money on input-heavy workloads. It only caps output, which was the small share.
  • Cap tool output before appending it to the next prompt.

Measure real usage in a day, then extrapolate

Estimates built from guesses are fine for a first pass, but real numbers take a few minutes to get. Every response includes a usage object with prompt and completion token counts, and responses carry an X-Balance-USD header showing your remaining balance. Log both, then multiply.

from openai import OpenAI

client = OpenAI(base_url="https://api.cosyvoice.top/v1", api_key="YOUR_KEY")

IN_RATE = 0.15 / 1_000_000
OUT_RATE = 0.50 / 1_000_000

resp = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarize the plot of Hamlet in five sentences."}],
)
u = resp.usage
cost = u.prompt_tokens * IN_RATE + u.completion_tokens * OUT_RATE
print(u.prompt_tokens, u.completion_tokens, round(cost, 6))

To read the balance header from the command line:

curl -si https://api.cosyvoice.top/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"uncensored","messages":[{"role":"user","content":"Say hello."}],"max_tokens":20}' \
  | grep -i x-balance-usd

Run your real prompts for a day or a week, take the average cost per request, and multiply by projected volume. Add a margin of 20 to 30 percent for retries and for prompts that grow as your product gains features.

Sizing your top-up

Balances are prepaid in whole dollars from $20 to $500. Bonuses are applied on top: +5% from $50, +10% from $100, +15% from $200. That gives these credit amounts:

You payBonusCredit
$20none$20.00
$505% = $2.50$52.50
$10010% = $10$110.00
$20015% = $30$230.00
$50015% = $75$575.00

To see what $20 buys, take a request with 1,000 input tokens and 500 output tokens. That costs $0.00015 + $0.00025 = $0.0004, so $20 covers 50,000 such requests. With the chat example above at $0.75 per day, a $20 balance lasts a little over 26 days.

Because credit never expires, there is little penalty for starting with the smallest amount and topping up when the balance header says you are low. Payment is by crypto (USDT on TRC20, USDC on Base). The pricing page has the current details.

Ways to bring the bill down

Once you have a measured baseline, there are only a few levers, and most of them act on input tokens.

  1. Shorten the system prompt. A 1,500-token system prompt sent 100,000 times is 150,000,000 input tokens, or $22.50. Cutting it to 600 tokens saves $13.50 on the same volume (900 tokens x 100,000 = 90,000,000 tokens x $0.15 / 1M).
  2. Summarize old turns. Replace the oldest half of a long history with a 300-token summary. You pay once to write the summary and save on every call after it.
  3. Send only the document sections that matter. If a question concerns chapter 4, do not send the other eleven chapters.
  4. Ask for the format you need. A JSON object with three fields costs fewer output tokens than a friendly paragraph around the same facts.
  5. Batch small related questions into one prompt when they share the same context, so the shared context is paid for once.

Output is the more expensive side per token, at $0.50 against $0.15, so a verbose model is worth correcting in the prompt. A 1,000-token answer costs $0.0005 in output alone, which is the same as sending 3,333 input tokens. Ask for brevity where brevity is acceptable.

Plan for variance

Averages hide spikes. A single user who pastes a 90,000-token document costs about $0.0135 in input for that one call, which is harmless alone, but a loop that does it every few seconds is not. Put a per-user daily cap in your own code and watch the balance header, and you will rarely be surprised.

Trial, free usage, and what is not free

Plainly: there is no free unlimited tier. The only free credit is a one-time $0.50 trial. After you sign up with Google or with email and password, you can claim it with one click on the API key page. It needs no card, lasts 7 days and is one per person. At the short Q&A size above ($0.00055 per call) it covers roughly 900 calls, which is enough to test integration and measure your own averages.

The trial key has lower limits than a funded key: 2 concurrent requests and 60 per minute, against 8 and 300 for a full key. A 429 response with code rate_limited or concurrency tells you which limit you hit. A streamed request holds its concurrency slot until the stream finishes, so long streams count against you for longer than their request time suggests.

Two budgeting notes for a commercial deployment. First, prompts are not used for training, which matters if your inputs come from customers. Second, the service is text only, so the cost model above covers everything you will be billed for on this side: no separate line for images, audio or embeddings, because those are not offered. The docs have the request format if you want to start measuring.

Questions and answers

Is there a monthly fee?

No. Billing is pay as you go from prepaid credit. You pay $0.15 per 1M input tokens and $0.50 per 1M output tokens, and credit never expires.

Am I charged for failed requests?

No. Failed or refused requests are not charged.

What is the cheapest way to test?

Claim the one-time $0.50 trial credit on the API key page after sign-up. It needs no card and is valid for 7 days.

How do I check my balance?

Each response includes an X-Balance-USD header with your remaining balance in dollars.

Does the bonus apply to every top-up?

Top-ups of $50 and above get +5%, $100 and above +10%, and $200 and above +15%. Smaller top-ups from $20 get no bonus.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.

Get API key