Post-processing
Post-processing
Post-processing
Post-processing steps let you apply automatic fixes to model responses after generation. You can specify an ordered list of steps in the post_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 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.
Add post_processing_steps to any chat completions request:
The JSON repair step corrects the most common JSON errors produced by LLMs:
The step applies to both message content and tool call arguments in the response.
If the JSON cannot be repaired, the request returns an HTTP 500 error. The raw malformed response is never passed through.
post_processing_steps works independently of response_format. You can use both together for maximum reliability:
post_processing_steps parameter