How tokens are counted & credits are charged — per model
This document explains, for the Rayu‑hosted (paid) models, exactly how token usage is turned into a credit charge, and the per‑model rate for every model currently offered.
TL;DR
- 1 credit = 1,000,000 tokens (the reference rate).
- Every model has a rate = credits per 1,000,000 tokens (its
creditMultiplier).- You are charged:
credits = tokens_used × rate ÷ 1,000,000, wheretokens_usedis the actual input + output tokens the model reported.- A failed or unavailable request costs 0 credits.
For the underlying mechanism (reserve/settle, cache‑aware billing, the Redis counter), see
credits-and-limits.md.
1. The charge formula
Charging happens in the gateway, off the model's real usage — not an estimate. For the active hosted models (served via Ollama Cloud), billing is flat: input tokens and output tokens are charged at the same rate, and there is no prompt‑cache discount, so:
billable_tokens = (input_tokens + output_tokens) × rate
credits_charged = billable_tokens ÷ 1,000,000
= tokens_used × rate ÷ 1,000,000
rate is the model's credits‑per‑1M‑tokens value (the creditMultiplier).
Because 1 credit = 1,000,000 tokens, the rate reads directly as “credits per
million tokens”.
rate = 1.0→ 1,000,000 tokens costs 1 creditrate = 2.5→ 1,000,000 tokens costs 2.5 creditsrate = 0.75→ 1,000,000 tokens costs 0.75 credits
Only tokens the provider actually reports are counted; the display in /usage
shows the real tokens used, not a rounded‑up number.
2. Per‑model rates
Rates below are the current defaults. All of them are admin‑editable in the
dashboard (Models → per‑model creditMultiplier); nothing here is hard‑coded
into the charge.
Notes:
- DeepSeek (official API) and Ollama Cloud are both active right now
(LongCat's provider row has
enabled = falsein Admin → Providers). A disabled provider's models are hidden from users and any request to them is refused (with no charge). DeepSeek V4 Flash/Pro are served DIRECT through DeepSeek's own Anthropic-compatible API (providerdeepseek); the remaining hosted models are served through Ollama Cloud. - MiniMax M3 and Llama 4 rates were not individually specified and use a sensible default (2.5 and 1.0) — adjust in the admin dashboard as needed.
- Context window is what the CLI reports for the model (used for context management). If a model is served by an upstream with a smaller real window, set a per‑model context override to avoid overflow.
Rate tiers at a glance
- 0.33 / 1M — DeepSeek V4 Flash (cheapest)
- 0.75 / 1M — GPT‑OSS 120B, Qwen3.5 397B, Qwen3.5 122B
- 1.0 / 1M — DeepSeek V4 Pro (reference), Llama 4
- 2.5 / 1M — GLM‑5.2, Kimi K2.7, MiniMax M3
3. Worked examples
Assume the reference rate (1 credit = 1,000,000 tokens).
A trivial message (e.g. a few thousand tokens) costs a tiny fraction of a credit — it is not rounded up to a whole credit.
4. What a plan buys
A plan grants a credit allowance per billing period (creditsPerPeriod).
Because 1 credit = 1,000,000 tokens, the allowance converts to tokens per
model by dividing by the model's rate.
Example — a plan with 50 credits / period:
Credits deplete over the period and reset at renewal. When the balance is
exhausted, further hosted requests return a credit‑limit error (or draw from
top‑up credits if the plan enables top‑up). Plan credit amounts and prices are
admin‑configured — see credits-and-limits.md.
5. Edge cases (what you are NOT charged for)
- Failed / errored request — if the upstream fails, usage settles to the real amount (0 for a failed turn), so a failed request costs 0 credits.
- Disabled provider — a request for a model whose provider is turned off
returns
503before any reserve, so it charges 0 credits and does not consume a daily turn. - Rate‑limited key — the gateway rotates/fails over across the provider's keys automatically; you are only charged for the request that actually succeeds, at the model's rate.
6. Where the numbers live (admin‑editable)
The gateway computes every charge from these values at request time — changing a rate in the dashboard changes the charge with no code change or redeploy of the CLI. The CLI is display‑only; the gateway is the single source of truth for billing.
