Structured outputs
Structured outputs make a model follow a JSON Schema definition that you provide as part of your inference API call. This is in contrast to the older JSON mode feature, which guaranteed valid JSON would be generated, but was unable to ensure strict adherence to the supplied schema. Structured outputs are recommended for function calling, extracting structured data, and building complex multi-step workflows.Getting started
- Python (Microsoft Entra ID)
- Python (key-based auth)
You can use If you are new to using Microsoft Entra ID for authentication see How to configure Azure OpenAI in Microsoft Foundry Models with Microsoft Entra ID authentication.
Pydantic to define object schemas in Python. Depending on what version of the OpenAI and Pydantic libraries you’re running you might need to upgrade to a newer version. These examples were tested against openai 1.42.0 and pydantic 2.8.2.Output
Function calling with structured outputs
Structured Outputs for function calling can be enabled with a single parameter, by supplyingstrict: true.
Structured outputs are not supported with parallel function calls. When using structured outputs set
parallel_tool_calls to false.- Python (Microsoft Entra ID)
- Python (key-based auth)
- Microsoft Entra ID
- API Key
Getting started
response_format is set to json_schema with strict: true set.
Function calling with structured outputs
JSON Schema support and limitations
Azure OpenAI structured outputs support the same subset of the JSON Schema as OpenAI.Supported types
- String
- Number
- Boolean
- Integer
- Object
- Array
- Enum
- anyOf
Root objects cannot be the
anyOf type.All fields must be required
All fields or function parameters must be included as required. In the example belowlocation, and unit are both specified under "required": ["location", "unit"].
null. In this example, this is achieved with the line "type": ["string", "null"],.
Nesting depth
A schema may have up to 100 object properties total, with up to five levels of nestingadditionalProperties: false must always be set in objects
This property controls if an object can have additional key value pairs that weren’t defined in the JSON Schema. In order to use structured outputs, you must set this value to false.Key ordering
Structured outputs are ordered the same as the provided schema. To change the output order, modify the order of the schema that you send as part of your inference request.Unsupported type-specific keywords
| Type | Unsupported Keyword |
|---|---|
| String | minlength maxLength pattern format |
| Number | minimum maximum multipleOf |
| Objects | patternProperties unevaluatedProperties propertyNames minProperties maxProperties |
| Arrays | unevaluatedItems contains minContains maxContains minItems maxItems uniqueItems |
Nested schemas using anyOf must adhere to the overall JSON Schema subset
Example supportedanyOf schema:
Definitions are supported
Supported example:Recursive schemas are supported
Example using # for root recursion:Currently structured outputs are not supported with:
- Bring your own data scenarios.
- Assistants or Foundry Agents Service.
gpt-4o-audio-previewandgpt-4o-mini-audio-previewversion:2024-12-17.
Supported models
gpt-5.1-codexversion:2025-11-13gpt-5.1-codex miniversion:2025-11-13gpt-5.1version:2025-11-13gpt-5.1-chatversion:2025-11-13gpt-5-proversion2025-10-06gpt-5-codexversion2025-09-11gpt-5version2025-08-07gpt-5-miniversion2025-08-07gpt-5-nanoversion2025-08-07codex-miniversion2025-05-16o3-proversion2025-06-10o3-miniversion2025-01-31o1version:2024-12-17gpt-4o-miniversion:2024-07-18gpt-4oversion:2024-08-06gpt-4oversion:2024-11-20gpt-4.1version2025-04-14gpt-4.1-nanoversion2025-04-14gpt-4.1-miniversion:2025-04-14o4-miniversion:2025-04-16o3version:2025-04-16
API support
Support for structured outputs was first added in API version2024-08-01-preview. It is available in the latest preview APIs as well as the latest GA API: v1.