Post-processing
Post-processing
Overview
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
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
Add post_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:
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.
Combining with structured outputs
post_processing_steps works independently of response_format. You can use both together for maximum reliability: