400
response_format 报错:Missing required parameter 'text.format.schema'
用 json_schema 做结构化输出时,schema 字段是必填的。
报错原文2026-10-23 实测
type 写了 json_schema,但只给了 name 没给 schema
{
"error": {
"message": "the upstream rejected this request as invalid (our request id: <请求ID>) — upstream said: Missing required parameter: 'text.format.schema'. (at text.format.schema); retrying the same payload will fail the same way — check the payload (most often a tool/function JSON Schema the upstream rejects). quote OUR request id to support",
"type": "invalid_request_error",
"param": null,
"code": "upstream_rejected_request"
}
}原因
我们发了 response_format: {"type": "json_schema", "json_schema": {"name": "x"}},上游返回缺少 schema。报错里的字段路径是 text.format.schema,和你写的 response_format.json_schema.schema 不一样,是因为网关把请求转换成了上游接口的格式,指的是同一个东西。
只想要“返回 JSON 就行”、不需要严格结构时,可以用 {"type": "json_object"},并在提示词里说明要输出 JSON。
排查步骤
- json_schema 模式下补上 schema(一个完整的 JSON Schema)。
- schema 的顶层通常是 type: object,并写好 properties 和 required。
- 只需要大致的 JSON 时,改用 json_object,省去写 schema。
正确写法
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "fruits",
"schema": {
"type": "object",
"properties": {"items": {"type": "array", "items": {"type": "string"}}},
"required": ["items"],
"additionalProperties": false
}
}
}