Fundamentals

Stop Sequence

Quick Answer

A string that signals the model to stop generating when encountered.

A stop sequence tells the model to stop generating output when it produces a specific string. Stop sequences are useful for constraining output length or format. For example, setting a stop sequence to '\n\n' makes the model stop after two newlines. This is simpler than max_tokens but more predictable. Multiple stop sequences can be provided. Common examples include conversation terminators or specific punctuation. Stop sequences are useful for structured outputs and limiting token consumption. They work best when the sequence is natural for your task.

Last verified: 2026-04-08

Compare models

See how different LLMs compare on benchmarks, pricing, and speed.

Browse all models →