Tokens, context and output length
How Aimogen Pro computes the token budget for a request, why generated content gets truncated, and the settings that control input and output length.
Almost every "the article stops mid-sentence" report comes down to token budgeting. This page explains how Aimogen Pro decides how much room a request has.
The two limits#
Every model has two separate limits, and confusing them causes most of the trouble:
| Limit | Meaning |
|---|---|
| Input / context window | How much prompt the model will accept |
| Output / completion limit | How much the model will generate in one reply |
They are very different numbers. gpt-4.1 accepts around a million input tokens but will only produce
about 32,000 in one reply. gpt-4o accepts 128,000 and produces up to about 16,000.
Aimogen Pro keeps per-model tables for both.
How the budget is computed#
For each request:
- The prompt is assembled — your template, placeholders expanded, plus any injected retrieval chunks and internet results.
- The prompt is tokenised locally to count its tokens.
- If the count exceeds the model input limit, the prompt is truncated to fit.
- The remaining room becomes the available output budget, capped by your Max Tokens setting.
Step 3 is important: the plugin trims the prompt rather than letting the provider reject the request. That keeps generation working, but it means content silently disappears from the end of a very long prompt.
Overriding context limits#
Four settings on Settings › Advanced AI Settings let you override the built-in input limits:
| Setting | Applies to | Default if empty |
|---|---|---|
Context Window Limit For gpt-3.5-turbo-1106 | The 16K GPT-3.5 models | The built-in table value |
Context Window Limit For gpt-4-1106 | GPT-4 turbo and newer OpenAI models | 128,000 |
Context Window Limit For Claude Models | Claude models | 100,000 |
Context Window Limit For Claude Models (200K) | Claude models in the 200K list | The built-in value |
When to lower one. To control cost. Input tokens are billed, and a model that accepts 390,000 tokens will happily bill you for them. Setting a lower limit forces earlier prompt truncation.
When to raise one. Rarely. If a provider increases a window and you do not want to wait for a plugin update.
Max Tokens#
Max Tokens caps the output. Defaults:
| Constant | Value | Where it applies |
|---|---|---|
AIMOGEN_DEFAULT_MAX_TOKENS | 2048 | General writer default |
AIMOGEN_BULK_CONTENT_MAX_TOKENS | 4096 | Bulk content generation |
AIMOGEN_DEFAULT_COMPLETION_TOKENS | 2000 | Completions |
AIMOGEN_MINIMUM_TOKENS_FOR_CHAT | 50 | Floor below which a chat request is not attempted |
AIMOGEN_MINIMUM_TOKENS_FOR_COMPLETIONS | 50 | Same, for completions |
AIMOGEN_MAX_HUGGINGFACE_TOKEN_COUNT | 2000 | Hard cap for Hugging Face |
AIMOGEN_MAX_OLLAMA_TOKEN_COUNT | 4000 | Hard cap for Ollama |
Rules of thumb for English prose: 1 token is roughly 0.75 words, so 2048 tokens is about 1,500 words and 4096 is about 3,000.
Why content gets truncated#
Symptom: the article stops mid-sentence, or the last section is missing.
Causes, in order of likelihood:
Max Tokensis too low. Raise it, but do not exceed the model output limit.- The model output limit was reached.
gpt-4o-minicannot produce 30,000 tokens no matter what you set. Generate in sections instead. - PHP timed out. The request was killed before the provider finished. Check
max_execution_time— see Recommended server configuration. - The prompt consumed the window. Long retrieval injection plus long internet results leaves no room for output.
Diagnose it in System & Logs › Usage Logs: the row records the request. A finish_reason of
length means the model hit the output cap; a truncated response with no finish_reason usually means
PHP or the network cut the connection.
Generating long content properly#
Do not ask for 5,000 words in one call. Every bulk creator supports section-by-section generation, which is both more reliable and better structured:
- Generate the title.
- Generate a section outline.
- Generate each section as a separate request.
- Generate the introduction and conclusion with the finished body available as context.
That is what the bulk creators do by default, and it is why they can produce far longer articles than a single call allows.
The %%article_so_far%%, %%last_section_content%% and %%current_section%% placeholders give each
call the context it needs. See Placeholder reference.
Two related settings on the rule:
| Setting | Effect |
|---|---|
Maximum Prompt Token Count To Use Per API Request | Caps prompt size per call |
Maximum Result Token Count To Use Per API Request | Caps output per call |
Maximum Continue Token Count To Use Per API Request | Caps the continuation call when content is extended |
Created Content Minimum Character Count | If the result is shorter, the plugin asks the model to continue |
Do not send max tokens at all#
Settings › General Settings › Don't Send Maximum Tokens In API Request (Experimental) omits the parameter entirely and lets the model decide.
The plugin help text names the specific case it was added for: content editing involving Chinese characters, where the token estimate is unreliable. It is a workaround, not a general setting. Leave it off unless you have that problem.
Counting tokens#
The plugin tokenises locally using a bundled BPE vocabulary. That gives a good estimate for OpenAI models and a reasonable one elsewhere — other providers use different tokenisers, so counts for Claude, Gemini and open models are approximate.
The consequence: on non-OpenAI models the budget is conservative. If you see truncation earlier than expected on Claude or Gemini, that is the estimate being cautious.
Related#
Still stuck? Open a support ticket and include the diagnostics from Aimogen Pro › System & Logs › System Info.