Skip to content
全部文章

按 schema 要一段 JSON

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

聊天请求上的一个字段

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

根必须是对象。非对象根会被包进 result。strict 为 false,与 Interfaze 公布的请求 一致。该跳上的 strict: true 会返回普通文本。

模型详情里有 Structured output 一行时才支持。这一行链到指南,并且只在路由声明了 response_format 或 structured_outputs 时出现。

相关文章