Skip to main content

Guides

Does Local AI Have Unlimited Tokens? How Ollama Limits Them

Local models use tokens but have no per-token bill. See which limits still apply, then measure how much context one prompt leaves with a short exercise.

By Updated 7 min read

Yes, a local model uses tokens, but you do not pay for them one by one. A token is a piece of text, often part of a word, that the model reads or writes. When a downloaded model runs on your own computer, there is no per-token bill and no message cap from a hosted service. Three limits still apply to every request:

  • Context length: your instructions, the conversation so far, any pasted or attached text, and the answer must fit in the context set in your app.
  • Output limit: the app or runner may stop one answer at a set number of tokens.
  • Your computer: a longer context needs more memory, and every token takes time and electricity.

This matters if you want local AI to avoid message caps, write often, or work offline. A very large document in one pass is a context and memory problem.

Try it: see how much room one prompt leaves

  1. Open the token counter with Qwen3 4B selected. It keeps 256 tokens for instructions and chat formatting and 512 for the reply, out of a 4,096-token context.

  2. Paste this sample and choose Count:

    Delivery note: The supplier will deliver 40 chairs to Room B on Tuesday, 12 May, if the deposit is paid by Friday. The deposit has not been paid yet. No delivery fee is stated.

    Using only the delivery note, give the delivery date, the condition, and the delivery fee. Say "not stated" for anything the note does not give.

  3. With Qwen3’s tokenizer the sample is 76 tokens. The counter adds 76 + 256 + 512 = 844 tokens and shows 3,252 tokens left for earlier messages and other text.

The count is exact only for the tokenizer it uses; another model splits the same text differently, and your app adds its own instructions and formatting. If the space left is small, raise the context only after checking memory, or send less text. Context windows works through a longer chat and an attachment.

Four limits that are easy to confuse

Qwen3.5's publisher specifies a native context of 262,144 tokens; start at 4,096 on a laptop. Reasoning tokens can consume output allowance and time even when the interface hides them. See the model's thinking controls.

LimitWhat it meansDoes running locally remove it?
Hosted usage allowanceMessages or tokens included by a serviceA fully local model need not use that service, but a selected cloud provider still does
Context lengthInstructions, conversation, supplied text, and answer space for a requestNo; the model, app, and available memory constrain it
Output allowanceHow long one answer may be generatedNo; the app or model runner may cap or stop the answer
Computing resourcesMemory, processing time, disk space, power, and heatNo; your computer supplies these

A token is a unit of text that a model reads or writes. It may be a word fragment, punctuation, or another piece of text. One token is not exactly one word, especially for code or non-English text.

Check that the request is really local

  1. Install a model runner and download a supported model.
  2. Select that local model in the chat app.
  3. Complete a short conversation, then test an offline restart.
  4. Check optional search, document, and tool providers separately.

If a new chat works after an offline restart, it does not need a hosted model.

Why the model stops halfway through an answer

An answer can stop for several reasons. It may hit its output allowance, reach a stop sequence, use up the context, or fail because the computer runs out of memory. Each cause needs a different fix.

In llama.cpp the output limit is -n (--predict; the default is -1, meaning no fixed limit). API requests use max_tokens, as in the request examples on the llama.cpp page. Other apps label this setting differently.

If a draft cuts off, ask for the remaining section and supply enough source text. You can also raise the output allowance if the app and memory allow it. If the model loops or repeats, stop the request and use answer troubleshooting. A setting with no limit can waste time without improving the answer.

Ollama context length and output limit

Ollama has two separate settings. Its documentation describes num_ctx as the size of the context window used to generate the next token. It describes num_predict as the maximum number of tokens to predict when generating text, with a default of -1, which the Modelfile page labels infinite generation. The API options list the same two: num_ctx as the context length (number of tokens) and num_predict as the maximum number of tokens to generate.

You can start another request after it finishes; each request still has a context limit. You can change it in the Ollama app's settings with the context length slider. You can also set the OLLAMA_CONTEXT_LENGTH environment variable when you start the server, for example OLLAMA_CONTEXT_LENGTH=64000 ollama serve. Ollama's context length page warns that a larger context length needs more memory.

To see what is running, use ollama ps. Ollama's documentation lists it as the command that shows running models. The context length page says its CONTEXT column shows the allocated context length. The FAQ says the PROCESSOR column shows where the model loaded: 100% GPU means entirely on the GPU, and a split such as 48%/52% CPU/GPU means part is in system memory.

Ollama's API also reports how many tokens a request used. The generate reference documents prompt_eval_count as the number of input tokens in the prompt and eval_count as the number of output tokens generated. It documents done_reason as the reason the generation stopped. Ollama's usage page lists the timing fields prompt_eval_duration and eval_duration, and says all timing values are measured in nanoseconds. Record done_reason, eval_count and your num_predict setting from the same response. If output ended at its cap, rerun with room for more output. To investigate missing source text, inspect the request your client sent and test facts from different positions in it.

Why a large document still does not fit

Use the token counter to estimate the text you will supply. Leave room for your instructions, the conversation so far, document passages, tool output, and the answer. For an exact count, use the model's own tokenizer.

Then check context windows and the memory calculator. Your computer cannot hold a published long-context limit. Document search supplies only the relevant passages instead of the whole document.

For example, ten separate short chats run repeatedly on a laptop. A single chat containing ten long documents can fail even though the combined number of tokens over the day is the same.

Costs and terms still apply

A computer you already own adds no purchase cost but uses electricity, battery, storage, and your time. Optional cloud models, paid app features, or remote tools add their own charges.

Use the cost calculator with your planned workload. It compares money costs under the assumptions you enter.

Sources