59API

← 返回教程列表

What Are Tokens? A Practical Counting and Billing FAQ

省钱与定价 · EN · 2026-10-23

Tokens are the units an AI model uses to process input and generate output. Understanding how they are counted helps you explain unexpected API charges, fix context errors, and choose sensible response limits. The key distinction: visible text length, context usage, and billable usage measure different things.

What is a token?

A tokenizer converts text into numbered pieces called tokens. A piece might represent a word, part of a word, punctuation, or whitespace. Common words may fit into one token; unfamiliar names, source code, and long identifiers can split into several.

For ordinary English prose, one token often corresponds to roughly four characters, or about three-quarters of a word. That makes 1,000 tokens approximately 750 words. Treat this as a planning estimate: language, formatting, and the model's tokenizer can change the result substantially.

How are input and output tokens counted?

Input tokens cover the content submitted for a request. Output tokens cover what the model generates. A short question can still produce a large input count when your application attaches conversation history, instructions, or retrieved documents.

For example, a request reporting 2,400 input tokens and 600 output tokens used 3,000 tokens overall. Its price still depends on the separate input and output rates.

How can I check the exact count?

A generic tokenizer is useful for estimates, but it cannot guarantee the count for every model. Do not assume Claude Sonnet 5.5 and GPT-6 Astra tokenize the same text identically.

Why is my token usage higher than expected?

Inspect the complete outbound request. Common causes include resending the entire chat, duplicating instructions, attaching oversized tool schemas, and returning full files from tools. Agent workflows can make several model requests for one user task; add usage across all those requests.

Images, audio, and video also consume capacity under model-specific rules. Their cost cannot reliably be estimated by counting characters in the surrounding message. Check the selected model's modality pricing and usage breakdown.

Why am I getting a context-length error?

The context window limits how much a request can accommodate. Input and generated output generally share that capacity, while output may have its own smaller limit. Exact rules vary by model and endpoint.

Reduce repeated history, summarize older turns, retrieve only relevant document sections, and shorten tool results. Then set an appropriate output limit. Increasing that limit can make a request exceed available context; it does not expand the model's window.

How do token counts become charges?

For ordinary text usage, calculate: input tokens divided by 1,000,000 times the input rate, plus output tokens divided by 1,000,000 times the output rate. Apply separate rates where caching or other categories require them. Cached tokens may already be included within reported input totals, so avoid adding them twice.

How can I lower costs with 59API?

59API provides low-cost, pay-as-you-go access to native, official-quality models without downgrading them. Its API base URL is https://api.59api.com, with compatibility for OpenAI SDKs, Claude Code, Codex, and Gemini CLI. Compare current model prices, trim unnecessary context, and measure cost per successfully completed task.

Sign up for 59API to test a small workload and compare actual usage; its referral rebate offers another potential saving.

价格 · 接入文档

准备好开始了吗?

几分钟接入 Claude 与 GPT,全网超低价,原生不降智。立即注册即可领取 API 密钥。

免费注册