Skip to main content
The 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 a response_healing entry to the plugins array.
The plugin takes no configuration. 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/completions that means response_format is json_object or json_schema. On /v3/router/responses it means text.format declares type: json_schema, or carries a non-empty inline schema body 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_format is 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_tokens may 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 a plugins array on each call. Once enabled, it applies automatically to every call that doesn’t already specify a response_healing plugin.

Supported endpoints