diff --git a/docs/api.md b/docs/api.md index 6a3c8b466..13c014143 100644 --- a/docs/api.md +++ b/docs/api.md @@ -924,6 +924,23 @@ custom stops cannot be combined with output constraints. For conversational JSON output, the schema and a JSON-only formatting instruction are included in the system prompt as well as enforced by token masks. +JSON Schema output constraints (`response_format` with `type: "json_schema"` on +Chat Completions and Completions, `text.format` on Responses, and +`output_config.format` on Messages) validate every schema node against a closed +keyword allowlist before grammar compilation. Accepted structural and constraint +keywords are `$ref` (same-document `#` references only), `$defs`, `definitions`, +`type`, `const`, `enum`, `anyOf`, `oneOf`, `allOf`, `properties`, +`patternProperties`, `additionalProperties`, `required`, `minProperties`, +`maxProperties`, `items`, `prefixItems`, `additionalItems`, `minItems`, +`maxItems`, `minLength`, `maxLength`, `pattern`, `format`, `minimum`, `maximum`, +`exclusiveMinimum`, `exclusiveMaximum`, and `multipleOf`. Accepted metadata and +annotation keywords are `$anchor`, `$schema`, `$id`, `id`, `$comment`, `title`, +`description`, `default`, `readOnly`, `writeOnly`, `examples`, +`contentMediaType`, and `contentEncoding`. Any other keyword (such as +`deprecated`, `nullable`, `uniqueItems`, or compiler extensions like +`x-guidance`), external `$ref` targets, and schemas exceeding 262,144 bytes, +depth 64, or 8,192 nodes return HTTP 400. + String stops (`stop`, or `stop_sequences` on Messages) accept at most four nonempty strings totaling at most 4096 UTF-8 bytes. Token stops (`stop_token_ids` and `stop_token_sequences`) accept at most sixteen nonempty