response_healing plugin repairs malformed JSON in model output before the response reaches the caller. Models asked for structured output sometimes wrap it in a markdown code fence, add a sentence of explanation around it, or emit a trailing comma. The plugin extracts and repairs the JSON so the response parses.
This feature is in Beta.
Use cases
- Getting reliable structured output from models with weaker JSON adherence.
- Removing per-service JSON cleanup code from application clients.
- Recovering tool calls whose arguments came back slightly malformed.
Quick start
Add aresponse_healing entry to the plugins array.
response-healing, the hyphenated spelling used by OpenRouter, is accepted as an alias for response_healing. Payloads migrated from OpenRouter work without edits.
What gets repaired
When it applies
The plugin repairs two things:- Message content, only when the request asks for JSON. On
/v3/router/chat/completionsthat meansresponse_formatisjson_objectorjson_schema. On/v3/router/responsesit meanstext.formatdeclarestype: json_schema, or carries a non-empty inlineschemabody without an explicit type. Requests that ask for plain text are never modified. - Tool call arguments, whenever the plugin is enabled. Arguments are JSON by definition, so no
response_formatis required.
Limits
- Non-streaming requests only. Streamed chunks reach the caller before the full body is known, so there is nothing left to repair. Setting the plugin on a streaming request has no effect.
- Output truncated by
max_tokensmay be unrecoverable. A response cut mid-string cannot be reconstructed. - Unrepairable output passes through unchanged. The plugin never fails a request, and never replaces valid JSON.
Enable for a workspace
Enable response healing for every request from Settings > Plugins, without passing aplugins array on each call. Once enabled, it applies automatically to every call that doesn’t already specify a response_healing plugin.