LLM Token, Context Window and API Cost Calculator

Paste your prompt, add attached documents, chat history and expected output, enter the context window and prices per million tokens, and see usage and cost.

Berjalan dalam pelayar anda. Fail anda tidak pernah meninggalkan peranti. Lihat cara menyemaknya

…

Cara melakukannya

  1. 1
    Paste your prompt

    Or a sample.

  2. 2
    Add other input

    Documents and history.

  3. 3
    Set expected output

    Tokens per reply.

  4. 4
    Enter window and prices

    From your provider.

  5. 5
    Read usage and cost

    Per call, day and month.

Tentang alat ini

Large language models read and write text as tokens: pieces of words. Costs, speed and limits are all measured in tokens, not words. A model's context window is the maximum number of tokens it can consider at once, including the system prompt, any attached documents, the conversation history and the answer. API pricing charges separately for input and output tokens, usually per million. This calculator estimates the tokens in your prompt, adds documents, history and the expected reply, shows how full the context window is and works out the cost per call, per day and per month using prices you enter.

Who this is for

Developers building with AI APIs, product managers estimating budgets, writers and researchers working with long documents, and students learning how language models work.

Estimating tokens

Exact counts depend on each model's tokenizer, but useful rules of thumb hold. English prose averages about 4 characters, or three quarters of a word, per token. Source code has more symbols and averages about 3 characters per token. Chinese, Japanese and Korean characters are often about one token each. The calculator applies these ratios to your text; for exact numbers, use your provider's token counter.

What fills the context window

Every call sends the system prompt, the user's message, any retrieved or attached documents, and the previous turns of the conversation. The reply also counts toward the window. Long chats grow quickly: ten turns of 350 tokens add 3,500 tokens before anything else. When the window is nearly full, applications summarise or drop old turns.

Cost

Cost per call = input tokens / 1,000,000 × input price + output tokens / 1,000,000 × output price. Output tokens usually cost several times more than input tokens. Multiply by calls per day for daily and monthly budgets. The table shows the cost for 1 to 10,000 calls.

A worked example

A 39-token instruction plus a 6,000-token document, four 350-token history turns and an 800-token reply uses about 8,240 tokens, 4.1% of a 200,000-token window. At 3 per million input tokens and 15 per million output tokens, each call costs about 0.034; 500 calls a day cost about 17 a day or 515 a month.

Reducing cost

Send only the relevant parts of documents, summarise long histories, cache repeated system prompts where the provider supports it, and set a sensible maximum output length.

## Planning a budget Start with a realistic sample of real requests rather than the shortest one. Note the typical document size, how many turns a conversation lasts and how long answers usually run, then enter those averages. Add a margin of 20% to 30% for retries, longer questions and growth in usage.

Limits

Token counts are estimates and prices change; check your provider's current list. This is general information, not financial advice.

Contoh berselesaian

About 8,240 tokens per call at 3/15 per million tokens costs about 0.034 per call.

Ringkasnya

Soalan lazim

How many words are in a token?

About 0.75 English words, or roughly 4 characters.

What is a context window?

The maximum number of tokens a model can consider at once, including the reply.

Why do output tokens cost more?

Generating text needs more computation per token than reading it.

Are the counts exact?

No, they are estimates; tokenizers differ by model.

How can I cut costs?

Shorten prompts, trim history and cap output length.

Is my text uploaded?

No. It is counted in your browser.

Percuma sepenuhnyaTiada bayaran, tiada pendaftaran
Fail kekal peribadiSemuanya berjalan dalam pelayar anda
Mudah dalam bahasa andaTersedia dalam banyak bahasa