> ## Documentation Index
> Fetch the complete documentation index at: https://docs.arouter.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 回應修復

> ARouter 在使用 json_schema 或 json_object 回應格式時，自動修復格式錯誤的 JSON 回應。

回應修復會在您請求結構化輸出時，自動修復模型回應中格式錯誤的 JSON。

## 啟用條件

僅當同時滿足以下兩個條件時：

1. `response_format` 設定為 `json_schema` 或 `json_object`
2. 回應本文是有效的 UTF-8，但包含可修復的 JSON 語法錯誤

## 修復內容

| 問題             | 修復後                |
| -------------- | ------------------ |
| Markdown 程式碼區塊 | `{"key": "value"}` |
| 尾隨逗號           | `{"a": 1, "b": 2}` |
| 未加引號的鍵         | `{"key": "value"}` |
| 混合文字 + JSON    | `{"id": 1}`        |
| 單引號字串          | `{"key": "value"}` |

## 偵測已修復的回應

```json theme={null}
{
  "choices": [{"message": {"role": "assistant", "content": "{\"name\": \"John Doe\"}"}, "finish_reason": "stop"}],
  "x_arouter": {"response_healed": true}
}
```

## 限制

* **僅限非串流** — 不適用於串流回應
* 不會修復截斷的輸出
* 僅修復語法錯誤，不修復語意錯誤

## 相關文件

* [結構化輸出](/zh-Hant/guides/features/structured-outputs)
* [外掛程式概覽](/zh-Hant/guides/features/plugins-overview)
