LLM
Apply stop sequences API
Applies stop sequences to raw/streamed model output: finds the earliest stop string and returns the text cut at (and excluding) it, plus which sequence matched and where — the deterministic equivalent of an API stop parameter for post-hoc trimming. Answers 'how do I cut model output at a stop token?', 'where does the first stop sequence appear?'.
Price$0.02per request
MethodPOST
Route/v1/llm/stop-sequence
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
llmstop-sequencetruncatestreamingoutputpost-processagenttrim
API URL
Integration docshttps://x402.hexl.dev/v1/llm/stop-sequenceExample request
{
"text": "The answer is 42.\nObservation: done",
"stop": [
"\nObservation:",
"END"
]
}Example response
{
"truncated": "The answer is 42.",
"matched": "\nObservation:",
"matchIndex": 17,
"wasTruncated": true
}Input schema
{
"type": "object",
"required": [
"text",
"stop"
],
"properties": {
"text": {
"type": "string",
"examples": [
"The answer is 42.\nObservation: done"
]
},
"stop": {
"type": "array",
"items": {
"type": "string"
},
"examples": [
[
"\nObservation:",
"END"
]
]
}
}
}Output schema
{
"type": "object",
"additionalProperties": true
}