# 按 schema 要一段 JSON

> Chat completion 接受 response_format。回答是 message.content 里的 JSON 字符串。请解析它。schema 的根保持为对象。

- Date: November 23, 2026
- Category: guides
- HTML: https://anyrouter.dev/blog/zh/structured-output

## 聊天请求上的一个字段

向 `/v1/chat/completions` 发送 `response_format.type` 为 `json_schema`。AnyRouter 原样转发。`choices[0].message.content` 是 JSON 字符串。请解析它。

根必须是对象。非对象根会被包进 `result`。`strict` 为 false，与 [Interfaze 公布的请求](https://interfaze.ai/docs/structured-output) 一致。该跳上的 `strict: true` 会返回普通文本。

模型详情里有 Structured output 一行时才支持。这一行链到[指南](https://anyrouter.dev/docs/guides/structured-output)，并且只在路由声明了 `response_format` 或 `structured_outputs` 时出现。
