Where the number comes from
A model API sells tokens, not keys. For glm api key pricing, the figures you need are the input rate, the output rate and any discount for cached or batched requests, all listed per 1M tokens on the provider's official pricing page. Rates and model names change, so we do not quote them here. Copy the current numbers into the table below and the rest of this article works for any provider.
A token is a chunk of text, roughly three quarters of an English word. Other languages and code can use more tokens per word. Your provider's tokenizer or the usage field in responses gives the exact count, which beats any rule of thumb.
You will also see terms such as context length, rate limit and tier on pricing pages. Only the first two rates change your bill. Context length caps how much you can send per request, and rate limits cap how fast you can send it. On this API the window is 100,000 tokens and a full key allows 8 concurrent requests and 300 per minute.
Count tokens per request
Write down four numbers for each type of request your application makes:
- Fixed input: system prompt and tool definitions.
- Variable input: user message, retrieved documents, chat history.
- Output: the typical reply length.
- Volume: requests per day.
Chat history is the usual surprise. Each turn resends everything before it, so a conversation of 10 turns does not cost 10 messages of input, it costs the sum of 1 + 2 + ... + 10 messages, which is 55 message units. Trim or summarize the history if conversations run long.
To measure rather than guess, log the usage block. On this API it is returned with every response, and with streaming it arrives at the end of the stream:
from openai import OpenAI
client = OpenAI(base_url="https://api.apikeyglm.com/v1", api_key="YOUR_KEY")
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Write a 100-word product blurb for a lamp."}],
stream=True,
stream_options={"include_usage": True},
)
for event in stream:
if event.usage:
print("in:", event.usage.prompt_tokens, "out:", event.usage.completion_tokens)For an early forecast, sample real data. Take 50 real user messages or documents, run them through, and use the average and the 90th percentile of token counts. The average gives you the expected bill, the percentile shows you how bad a heavy month looks.
Worked example 1: a chatbot
500 users a day send 6 messages each, so 3,000 requests. Each request averages 2,000 input tokens (history plus system prompt) and 300 output tokens.
- Daily input: 3,000 x 2,000 = 6M tokens, so 6 x $0.15 = $0.90.
- Daily output: 3,000 x 300 = 0.9M tokens, so 0.9 x $0.50 = $0.45.
- Daily total: $1.35. Over 30 days: $40.50.
Worked examples 2 and 3: batch and retrieval
Summarize 50,000 documents, each 1,500 tokens long, into 150-token summaries.
- Input: 50,000 x 1,500 = 75M tokens, so 75 x $0.15 = $11.25.
- Output: 50,000 x 150 = 7.5M tokens, so 7.5 x $0.50 = $3.75.
- Total: $15.00.
Batch work has one more lever: it can run in parallel, but a full key is limited to 8 concurrent requests and 300 requests per minute, so 50,000 requests need at least 167 minutes at the per-minute cap (50,000 / 300). Plan the wall-clock time as well as the cost.
Worked example 3: retrieval-augmented answers
A support assistant handles 20,000 questions a month. Each sends 8,000 input tokens (instructions plus retrieved passages) and gets a 400-token answer.
- Input: 20,000 x 8,000 = 160M tokens, so 160 x $0.15 = $24.00.
- Output: 20,000 x 400 = 8M tokens, so 8 x $0.50 = $4.00.
- Total: $28.00 a month.
The context window here is 100,000 tokens, prompt plus completion, so 8,000 tokens of context leaves a lot of room. Input is 86 percent of this bill, which is typical for retrieval: cutting retrieved text matters more than shortening answers.
How request size changes the price
Price per 1,000 requests is a handy unit because it scales by simple multiplication. Here are four request shapes at $0.15 and $0.50 per 1M tokens:
| Request shape | Input cost per 1,000 | Output cost per 1,000 | Total per 1,000 |
|---|---|---|---|
| 500 in, 200 out | $0.075 | $0.100 | $0.175 |
| 2,000 in, 300 out | $0.300 | $0.150 | $0.450 |
| 8,000 in, 400 out | $1.200 | $0.200 | $1.400 |
| 30,000 in, 1,000 out | $4.500 | $0.500 | $5.000 |
The pattern is plain. Short chat requests are cheap and output-heavy. Large-context requests are input-heavy, and the input line dominates. Knowing which type you run tells you which lever to pull: shorter replies for the first, trimmed context for the second.
Mistakes that make estimates wrong
- Counting words instead of tokens. A 1,000-word English text is roughly 1,300 tokens, and more for code or non-English text.
- Forgetting the history. Chat input grows each turn, as shown above.
- Using averages for spiky traffic. A launch day can be ten times a normal day. Budget for the peak you can survive.
- Ignoring retries. Add a margin. On this API failed or refused requests are not charged, but check this for any provider you compare.
- Skipping the output cap. Output costs more per token. If you only need a label or a short summary, ask for it, and set
max_tokenswhere a hard limit helps. It is optional here.
Compare with GLM's rates
Fill in this table with the provider's current numbers and your own volumes:
| Line | This API | GLM (check current pricing) |
|---|---|---|
| Input rate per 1M | $0.15 | look up |
| Output rate per 1M | $0.50 | look up |
| Cached input discount | not part of the rate card | look up |
| Failed requests charged | no | look up |
| Payment | prepaid crypto, no expiry | look up |
Then compare on more than price. Refusal behavior, context length and whether the model follows your output format all change how many retries you pay for. This API serves one open-weight model, uncensored, tuned to answer without content refusals for lawful adult use. It is an independent service and not the official API of Zhipu, Z.ai or any other vendor. For a look at a similar integration, the site's Kimi apikey integration guide follows the same pattern.
Budgeting and top-ups
Add 20 to 30 percent to your estimate for retries, longer prompts and growth. The chatbot at $40.50 becomes a budget of about $49 to $53. Top up in whole amounts from $20 to $500; a $50 top-up adds +5% and gives $52.50 of credit, $100 adds +10% for $110.00, and $200 adds +15% for $230.00. Payment is crypto only, USDT on TRC20 or USDC on Base, and credit never expires.
New users can try the endpoint with $0.50 of trial credit, valid for 7 days. At 2,300 tokens per request in the chatbot example, that is about 1,100 test requests. Open the pricing page for the full rate card, then get a key and read the docs for limits and headers.
Finally, set an alert. Each response includes X-Balance-USD, so a few lines of code can warn you when credit falls below a number of days of spend. The Kimi apikey integration guide shows the same kind of client setup in a related context.
