Why use them
Stop sequences keep replies from running past the part you want. Common uses:
- One item only. Stop at
"\n"to get a single line. - Fixed formats. If you've asked for an answer followed by a marker like
END, stop at"END". - Role play or transcripts. Stop at
"User:"so the model doesn't write the other side of the conversation.
They also save output tokens, because the model stops early instead of writing text you'd throw away.
Things to watch
- Pick strings that won't show up by accident in a good answer.
- The match is on exact text.
"END"won't match"end". - Stop sequences are a cutoff, not a format guarantee. If you need structured data, see JSON Mode.
Example
This asks for a list but stops after the first line.
curl https://api.luv13.ai/v1/chat/completions \
-H "Authorization: Bearer $LUV13_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "luv13/glm-5.3-flash",
"messages": [{"role": "user", "content": "List three fruits, one per line."}],
"stop": ["\n"]
}'