n4nAI

Topic

Max Tokens, Stop Sequences & Output Truncation

8 posts on max tokens, stop sequences & output truncation — part of glossary on the n4n AI blog.

GlossaryAnalysis

Why your LLM response cuts off mid-sentence

Your LLM response cuts off mid-sentence because of max_tokens, stop sequences, or provider limits. Here's how to diagnose and fix each cause.

4 min read
GlossaryDefinition

What does max_tokens actually control in an API call?

A precise technical explanation of what max_tokens controls in LLM API calls, how it interacts with context windows and stop sequences, and common misconceptions that cause production bugs.

4 min read
GlossaryGuide

Max tokens explained: input, output, and total limits

Understand how max tokens, input limits, and output budgets interact across providers — with code patterns for safe truncation, streaming, and cost control.

3 min read
GlossaryListicle

Max output tokens by model: GPT-4o, Claude, and Gemini

Compare max output tokens across GPT-4o, Claude, and Gemini with practical guidance for handling truncation and stop sequences in production.

3 min read
GlossaryHow-to

How to set max_tokens for long-form content generation

A step-by-step guide to configuring max_tokens for long-form content generation, covering model limits, chunking strategies, and verification techniques.

4 min read
GlossaryHow-to

How to detect and handle truncated LLM responses

Learn to detect truncated LLM responses using finish_reason and usage fields, then implement retries, continuation prompts, and monitoring to handle incomplete outputs reliably.

3 min read
GlossaryHow-to

How stop sequences work in the OpenAI and Claude APIs

Learn how stop sequences control LLM output termination in OpenAI and Claude APIs with practical code examples and verification steps.

4 min read
GlossaryListicle

Common max_tokens mistakes that truncate JSON output

Seven max_tokens mistakes that silently truncate JSON output, with fixes for token budgeting, reasoning models, streaming, and provider quirks.

4 min read