Documentation Index
Fetch the complete documentation index at: https://assemblyai.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Post-processing steps let you apply automatic fixes to model responses after generation. You can specify an ordered list of steps in thepost_processing_steps parameter on any chat completions request. Steps run server-side on all LLM Gateway models in both US and EU regions.
Currently, JSON repair (json-repair) is the only supported step type.
JSON repair
JSON repair corrects common JSON errors — such as trailing commas, unescaped characters, and missing quotes — that LLMs occasionally produce. This is especially useful when using structured outputs or tool calling, where invalid JSON would otherwise require client-side retry logic. If the response content cannot be repaired, the request returns an error rather than passing through broken JSON.Getting started
Addpost_processing_steps to any chat completions request:
- Python
- JavaScript
What JSON repair fixes
The JSON repair step corrects the most common JSON errors produced by LLMs:| Error type | Example (broken) | After repair |
|---|---|---|
| Trailing comma | {"name": "John",} | {"name": "John"} |
| Unescaped characters | {"note": "say "hi""} | {"note": "say \"hi\""} |
| Missing closing bracket | {"name": "John" | {"name": "John"} |
| Single-quoted strings | {'name': 'John'} | {"name": "John"} |
If the JSON cannot be repaired, the request returns an HTTP 500 error. The raw malformed response is never passed through.
Combining with structured outputs
post_processing_steps works independently of response_format. You can use both together for maximum reliability:
API reference
post_processing_steps parameter
| Key | Type | Required? | Description |
|---|---|---|---|
post_processing_steps | array | No | An ordered list of post-processing steps to apply to the response. Omit to disable post-processing. |
post_processing_steps[i].type | string | Yes | The step type. Currently "json-repair" is supported. |
Supported step types
| Type | Applies to | Models | Regions |
|---|---|---|---|
json-repair | Message content and tool call arguments | All LLM Gateway models | US and EU |