JZS Token Pricing Explained: Calculate and Optimize API Costs
What Is a Token?
A token is the smallest unit of text a language model processes. It is not equivalent to a single character or word—its size depends on the language and tokenization algorithm.
For English text, 1 token typically represents about 4 characters or 0.75 words. For example, "ChatGPT is great" is roughly 4 tokens.
Chinese characters require more complex Unicode encoding, so 1 character usually becomes 1-2 tokens. This means identical content in Chinese typically consumes 30-80% more tokens than English. Applications serving Chinese users should budget accordingly.
Input vs. Output Tokens
LLM API billing splits into input tokens (what you send) and output tokens (what the model generates), each with different rates. Output token prices are typically 3-5x higher than input tokens due to generation costs.
Input tokens include your system prompt, user messages, and conversation history. Output tokens are the model's generated response. Check our /model-pricing page for current rates across different models.
Estimating Token Usage
Accurate estimation prevents billing surprises. A single conversation consists of:
Total Tokens = System Prompt + History + Current Input + Output
For a customer service bot with a 500-token system prompt, 1,000 tokens of conversation history, 100-token user input, and 300-token response, a single request uses approximately 1,900 tokens total (1,600 input + 300 output).
Prompt Caching
Prompt caching lets the model reuse computation for repeated prefix content like system prompts. When cache hits, those tokens are priced at roughly 10% of the standard input rate.
Place static content (system prompts, fixed context) at the beginning of your message array and dynamic content (user input) at the end to maximize cache effectiveness. With longer system prompts containing knowledge base content (2,000-5,000 tokens), savings can reach 30-50%.
Optimization Strategies
1. Keep Prompts Concise
Verbose system prompts waste tokens. A well-crafted 200-token prompt often performs as well as an 800-token version. Remove redundant instructions, unnecessary examples, and over-detailed formatting requirements.
2. Match Model to Task
Not every task requires a flagship model. Lightweight models handle classification, extraction, and simple transformations at a fraction of the cost—often 10-60x less. Use smaller models for simple tasks and reserve larger models for complex reasoning.
3. Leverage Caching
Structure your requests so that repeated content appears first. For multi-turn conversations, maintain consistent message prefixes to improve cache hit rates.
4. Use Batch APIs for Non-Real-Time Tasks
If you have bulk processing needs like batch translation or summarization, batch APIs offer approximately 50% discounts. Though responses may take up to 24 hours, this is ideal for offline workflows.
5. Cap Output Length
Use the max_tokens parameter to prevent unnecessary long responses. Adding "keep it brief" to your prompt also reduces output token generation.
Pay-as-You-Go vs. Pre-Paid Credits
Pay-as-you-go offers flexibility—pay only for what you use—but typically at higher per-unit rates.
Pre-paid credits usually offer 5-20% discounts. Many platforms provide non-expiring balances, which eliminates end-of-month waste. For teams with stable monthly spend, pre-paid is generally more economical.
Summary
Token billing optimization comes down to four practices: understand your token composition, choose models appropriate to each task, maximize cache hits for repeated content, and leverage batch processing for volume work. Visit our /model-pricing page to estimate costs for your specific use case.