TokenPad
Prompts

Stop Sequence Tester

See exactly where generation stops, and what you paid for after it.

Your input

84 characters5 lines0 tokensor drop a file

Stop Sequence TesterExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

What stop sequences do

A stop sequence tells the API to halt generation the moment a given string appears. It is the cheapest way to prevent a model from rambling past the answer you wanted, and it is under-used because the behaviour is easy to get subtly wrong.

The sequence itself is typically not included in the returned text, which surprises people parsing the output for it.

What you are billed for

Tokens generated before the stop. Generation halts at that point, so nothing is produced afterwards — which is precisely why a well-chosen stop sequence saves real money on a verbose model.

This is the opposite of trimming after the fact. Truncating in your own code costs you the full generation; stopping at the source does not.

Choosing one that works

It must be a string the model will actually produce, and never one it might produce inside a valid answer. A double newline is a common choice for single-paragraph answers and a poor one for anything multi-paragraph.

For structured output, a closing delimiter you specified in the prompt is usually ideal — you told the model to end with it, so it is both predictable and unambiguous.

Frequently asked questions

Why is my stop sequence never triggering?
Usually because the model never generates it. Test with real output rather than assumed output — the string you expect and the string produced often differ in whitespace.
Is the stop sequence included in the response?
Generally not, though it varies by provider. Test rather than assume, since a parser expecting the delimiter will fail on the first response without it.
How does this interact with max_tokens?
Whichever comes first ends generation. Keep max_tokens as a safety ceiling and use stop sequences for the expected end — and note that some providers count max_tokens against your rate-limit quota regardless of what was generated.

More prompts tools