Skip to main content
You can use JSON Schema to define the structure of JSON objects returned by the model. We support most features from the JSON Schema 2020-12 specification across all of our products. We follow the specification unless otherwise noted.
The request will fail if you pass a JSON Schema that contains keywords or combinations of keywords that are not supported. The error message will specify the unsupported construct. Don’t hesitate to reach out to us to request support.

Quick reference

KeywordStatusNotes
typestring, number, integer, boolean, null, array, object
minLength / maxLengthStrings; counts characters
patternMost regex features; see unsupported patterns below
formatStrictly enforced at generation time. Supports: email, hostname, ipv4, uri, uri-reference, uuid, date, time, date-time, duration
enumWorks for any type
constWorks for any type
minimum / maximumNumbers and integers
exclusiveMinimum / exclusiveMaximumNumbers and integers
multipleOfOn integers
itemsHomogeneous arrays (see note below)
prefixItemsTuple validation (heterogeneous arrays)
minItems / maxItemsArray length
requiredFor object properties
Optional fields
$defs + $refInternal refs only (no external refs)
Recursive schemasUnlimited depth
anyOfIncluding at the root
allOf
oneOfTreated as anyOf
additionalPropertiesDefaults to false
{}Arbitrary JSON
{"type": "object"}Arbitrary object fields
propertyNames
not
if / then / else
dependentRequired
patternProperties
minProperties / maxProperties
contains-Request support
mincontains / maxcontains-Request support
uniqueItems-Request support
dependentSchemas-Request support
unevaluatedProperties / unevaluatedItems-Request support
$dynamicRef-Request support
$dynamicAnchor-Request support
items can also be used for tuple validation along with additionalItems per the draft 2019-09 specification. We recommend using prefixItems for tuple validation and items for homogeneous arrays or extra items beyond the prefixItems tuple.

Unsupported regular expressions

The pattern keyword supports most common regex features. The following are not supported:
  • Word boundaries (\b)
  • Backreferences (\1, (?P=open))
  • Conditional matches ((?(1)a|b))
  • Lookaheads (foo(?=bar))
  • Lookbehinds ((?<=foo)bar)
  • Atomic groups ((?>pattern))
  • Recursion ((?R), (?1))
  • Named captures ((?P<name>pattern))
  • Inline modifiers ((?i)case-insensitive)
  • Subroutines (\g<1>)
  • Branch resets ((?|pattern1|pattern2))
  • Inline comments ((?#comment))
  • Code callouts ((*MARK:name))
  • Version checks ((*VERSION))
  • Whitespace-insensitive patterns ((?x)pattern # comment)

Next steps