openai ยท OpenAI Platform Docs
Structured model outputs | OpenAI API
Teaches how to implement and configure the Structured Outputs feature to ensure model responses strictly adhere to a provided JSON Schema.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Structured model outputs | OpenAI API
Teaches how to implement and configure the Structured Outputs feature to ensure model responses strictly adhere to a provided JSON Schema.
When To Use
Use when you need to force an LLM to return data that matches a specific JSON schema for programmatic parsing and validation.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/structured-model-outputs-openai-api-workflow-guide.md | A guide and code example demonstrating how to use Pydantic models to enforce structured JSON schema responses via the OpenAI API. | Questions about a guide and code example demonstrating how to use Pydantic models to enforce structured JSON schema responses via the... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-nodejs-zod.text | A Node.js code example using the OpenAI SDK and Zod to implement structured model outputs with a defined schema. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod to implement structured model outputs with a defined schema. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-p.text | A Python code example using Pydantic models and the OpenAI client to parse structured chat completions. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models and the OpenAI client to parse structured chat completions. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-nodejs.text | A Node.js code example using the OpenAI SDK and Zod schema to parse structured model outputs. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod schema to parse structured model outputs. |
examples/structured-model-outputs-openai-api-openai-api-pydantic-structured-outpu.text | A Python code example using the OpenAI client and Pydantic to parse model responses into a structured CalendarEvent schema. | Exact payloads, commands, or snippets shown in A Python code example using the OpenAI client and Pydantic to parse model responses into a structured CalendarEvent s... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-nodejs-zod-2.text | A Node.js code example using the OpenAI SDK and Zod to implement structured model outputs with a math reasoning schema. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod to implement structured model outputs with a math reasoning schema. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-m.text | A Python example using Pydantic models to enforce structured math reasoning outputs via the OpenAI Chat Completions API. | Exact payloads, commands, or snippets shown in A Python example using Pydantic models to enforce structured math reasoning outputs via the OpenAI Chat Completions API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-nodejs-zod-3.text | A Node.js code example using the OpenAI SDK and Zod schema to enforce structured math reasoning outputs. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod schema to enforce structured math reasoning outputs. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-m-2.text | A Python example using Pydantic models and the OpenAI client to enforce structured math reasoning outputs. | Exact payloads, commands, or snippets shown in A Python example using Pydantic models and the OpenAI client to enforce structured math reasoning outputs. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-2.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json.text | A text representation of a JSON schema used to enforce structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A text representation of a JSON schema used to enforce structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-chat-completions-parse-zod.text | A JavaScript code example demonstrating how to use the OpenAI SDK with Zod schemas to enforce structured model outputs. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use the OpenAI SDK with Zod schemas to enforce structured model outputs. |
examples/structured-model-outputs-openai-api-openai-api-pydantic-structured-outpu-2.text | A Python code example using Pydantic models and the OpenAI client to parse structured model outputs. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models and the OpenAI client to parse structured model outputs. |
examples/structured-model-outputs-openai-api-openai-api-chat-completions-structur.text | A curl command demonstrating how to request structured model outputs from the OpenAI chat completions endpoint using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI chat completions endpoint using... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-nodejs-zod-4.text | A Node.js code example using the OpenAI SDK and Zod to enforce a structured schema for extracting research paper metadata. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod to enforce a structured schema for extracting research paper meta... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-p-2.text | A Python code example using Pydantic models and the OpenAI client to parse structured responses from the gpt-4o-2024-08-06 model. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models and the OpenAI client to parse structured responses from the gpt-4o-2024-... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-3.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-2.text | A JSON object demonstrating a structured model output following a specific schema for a research paper title and authors. | Exact payloads, commands, or snippets shown in A JSON object demonstrating a structured model output following a specific schema for a research paper title and auth... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-ui.text | A TypeScript code example using Zod to define a recursive UI component schema for OpenAI structured outputs. | Exact payloads, commands, or snippets shown in A TypeScript code example using Zod to define a recursive UI component schema for OpenAI structured outputs. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-p-3.text | A Python code example using Pydantic models to enforce structured outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to enforce structured outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-chat-completions-structur-2.text | A curl command demonstrating how to request structured model outputs using the gpt-4o-2024-08-06 model via the chat completions endpoint. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs using the gpt-4o-2024-08-06 model via the chat c... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-nodejs-zod-5.text | A Node.js code example using the OpenAI SDK and Zod to define a recursive UI component schema for structured model outputs. | Exact payloads, commands, or snippets shown in A Node.js code example using the OpenAI SDK and Zod to define a recursive UI component schema for structured model ou... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-p-4.text | A Python code example using Pydantic models to enforce structured outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to enforce structured outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-4.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-3.text | A JSON schema example demonstrating how to define a structured form object for model output parsing. | Exact payloads, commands, or snippets shown in A JSON schema example demonstrating how to define a structured form object for model output parsing. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-compli.text | A TypeScript code example using the OpenAI SDK and Zod schema to enforce structured content compliance responses. | Exact payloads, commands, or snippets shown in A TypeScript code example using the OpenAI SDK and Zod schema to enforce structured content compliance responses. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-c.text | A Python code example using Pydantic models to enforce structured content compliance schema via the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to enforce structured content compliance schema via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-5.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON schema. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-zod-co.text | A JavaScript code example using the OpenAI SDK and Zod schema to enforce structured content compliance responses. | Exact payloads, commands, or snippets shown in A JavaScript code example using the OpenAI SDK and Zod schema to enforce structured content compliance responses. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-python-pyd.text | A Python code example using Pydantic models to enforce structured content compliance checks via the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to enforce structured content compliance checks via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-6.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON schema. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-4.text | A JSON object demonstrating a schema definition for enforcing structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON object demonstrating a schema definition for enforcing structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-m-3.text | A Pydantic model definition used to enforce structured response schemas for OpenAI API calls. | Exact payloads, commands, or snippets shown in A Pydantic model definition used to enforce structured response schemas for OpenAI API calls. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-defini.text | A Zod schema definition for structuring model responses with steps and a final answer. | Exact payloads, commands, or snippets shown in A Zod schema definition for structuring model responses with steps and a final answer. |
examples/structured-model-outputs-openai-api-openai-chat-completions-parse-python.text | A Python code example demonstrating the use of the client.chat.completions.parse method with a structured MathResponse format. | Exact payloads, commands, or snippets shown in A Python code example demonstrating the use of the client.chat.completions.parse method with a structured MathRespons... |
examples/structured-model-outputs-openai-api-openai-chat-completions-parse-zod-ma.text | A JavaScript code snippet demonstrating how to use the openai.chat.completions.parse method with a Zod schema to enforce structured model outputs for a math tutor interaction. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to use the openai.chat.completions.parse method with a Zod schema to enfo... |
examples/structured-model-outputs-openai-api-openai-chat-completions-structured-o.text | A Node.js code example demonstrating how to use the OpenAI Chat Completions API to enforce structured model outputs using a math tutor system prompt. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI Chat Completions API to enforce structured model outputs u... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-python.text | A Python code example demonstrating how to use the OpenAI API to enforce structured model outputs using a chat completion request. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI API to enforce structured model outputs using a chat comple... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-s.text | A text example demonstrating the implementation of the response_format parameter using json_schema and strict mode in the OpenAI API. | Exact payloads, commands, or snippets shown in A text example demonstrating the implementation of the responseformat parameter using jsonschema and strict mode in t... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json.text | A text example demonstrating the implementation of the json_schema format with strict mode enabled for structured model outputs. | Exact payloads, commands, or snippets shown in A text example demonstrating the implementation of the jsonschema format with strict mode enabled for structured mode... |
examples/structured-model-outputs-openai-api-openai-chat-completions-structured-o-2.text | A Python code example demonstrating how to use the OpenAI Chat Completions API with structured outputs to guide a user through a math problem. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI Chat Completions API with structured outputs to guide a use... |
examples/structured-model-outputs-openai-api-openai-chat-completions-structured-o-3.text | A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses via the OpenAI Chat Completions API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses via the... |
examples/structured-model-outputs-openai-api-openai-api-chat-completions-structur-3.text | A curl command demonstrating how to request structured model outputs using the chat completions endpoint with a specific model and JSON schema. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs using the chat completions endpoint with a speci... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-gpt-4o.text | A Python code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses using the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses using the... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-gpt-4o-2.text | A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses via the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured responses via the... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-curl-r-7.text | A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and JSON payload. | Exact payloads, commands, or snippets shown in A curl command demonstrating how to request structured model outputs from the OpenAI API using a specific model and J... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-gpt-4o-3.text | A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured math tutor responses via the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the gpt-4o-2024-08-06 model to generate structured math tutor respons... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-python-mat.text | A Python code example demonstrating how to use the OpenAI API to enforce structured model outputs using a math tutor system prompt. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI API to enforce structured model outputs using a math tutor... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-v.text | A Python code example demonstrating how to use Pydantic models to define schemas for structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use Pydantic models to define schemas for structured model outputs via the... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-typescript.text | A TypeScript code snippet demonstrating how to define interfaces that match a JSON Schema for structured model outputs. | Exact payloads, commands, or snippets shown in A TypeScript code snippet demonstrating how to define interfaces that match a JSON Schema for structured model outputs. |
examples/structured-model-outputs-openai-api-openai-api-python-structured-outputs.text | A Python code example using Pydantic models and the OpenAI client to enforce structured math reasoning outputs. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models and the OpenAI client to enforce structured math reasoning outputs. |
examples/structured-model-outputs-openai-api-openai-chat-completions-parse-zod-2.text | A TypeScript code example demonstrating how to use the openai.chat.completions.parse method with a Zod schema to enforce structured model outputs. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use the openai.chat.completions.parse method with a Zod schema to enfo... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-chat-c.text | A JSON-formatted chat completion response demonstrating the structure of a model output when using the structured outputs feature. | Exact payloads, commands, or snippets shown in A JSON-formatted chat completion response demonstrating the structure of a model output when using the structured out... |
examples/structured-model-outputs-openai-api-openai-structured-outputs-api-respon.text | A JSON object representing a successful API response containing structured model output data. | Exact payloads, commands, or snippets shown in A JSON object representing a successful API response containing structured model output data. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-pydantic-p-5.text | A Python code example using Pydantic models to implement structured outputs with the OpenAI Chat Completions API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to implement structured outputs with the OpenAI Chat Completions API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-typesc.text | A TypeScript code example demonstrating how to use Zod schemas to enforce structured model outputs via the OpenAI beta chat completions stream API. | Exact payloads, commands, or snippets shown in A TypeScript code example demonstrating how to use Zod schemas to enforce structured model outputs via the OpenAI bet... |
examples/structured-model-outputs-openai-api-openai-api-pydantic-structured-outpu-3.text | A Python code example using Pydantic models to implement structured outputs with the OpenAI Chat Completions API. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to implement structured outputs with the OpenAI Chat Completions API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-nodejs.text | A Node.js code example using Zod schema and the OpenAI SDK to implement streaming structured model outputs. | Exact payloads, commands, or snippets shown in A Node.js code example using Zod schema and the OpenAI SDK to implement streaming structured model outputs. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-python-pyd-2.text | A Python code example using Pydantic models to enforce structured outputs via the OpenAI client. | Exact payloads, commands, or snippets shown in A Python code example using Pydantic models to enforce structured outputs via the OpenAI client. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-nodejs-2.text | A Node.js code example demonstrating how to use Zod schemas to enforce structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use Zod schemas to enforce structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-2.text | A JSON schema definition for a userdata object used to demonstrate strict structured outputs in the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition for a userdata object used to demonstrate strict structured outputs in the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-w.text | A JSON schema definition for a weather data object used to enforce structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition for a weather data object used to enforce structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-zod-valida.text | A TypeScript code snippet demonstrating the use of Zod to define discriminated union schemas for OpenAI structured model outputs. | Exact payloads, commands, or snippets shown in A TypeScript code snippet demonstrating the use of Zod to define discriminated union schemas for OpenAI structured mo... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-3.text | A JSON schema definition demonstrating the use of strict mode for structured model outputs in the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition demonstrating the use of strict mode for structured model outputs in the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-4.text | A JSON schema definition for a weather fetching tool used to demonstrate structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition for a weather fetching tool used to demonstrate structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-json-5.text | A JSON schema definition demonstrating the use of strict mode for structured model outputs in the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition demonstrating the use of strict mode for structured model outputs in the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-5.text | A JSON schema definition used to enforce structured model outputs via the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition used to enforce structured model outputs via the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-6.text | A JSON schema definition demonstrating how to enforce structured model outputs using the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON schema definition demonstrating how to enforce structured model outputs using the OpenAI API. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-ui-co.text | A JSON schema definition for a dynamically generated UI component used to demonstrate structured model outputs. | Exact payloads, commands, or snippets shown in A JSON schema definition for a dynamically generated UI component used to demonstrate structured model outputs. |
examples/structured-model-outputs-openai-api-openai-structured-outputs-json-linke.text | A JSON schema definition for a linked list structure used to demonstrate OpenAI structured model outputs. | Exact payloads, commands, or snippets shown in A JSON schema definition for a linked list structure used to demonstrate OpenAI structured model outputs. |
examples/structured-model-outputs-openai-api-openai-chat-completions-structured-o-4.text | A Node.js code example demonstrating how to use the OpenAI Chat Completions API to enforce structured JSON outputs using a specific model. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI Chat Completions API to enforce structured JSON outputs us... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-python-2.text | A Python code example demonstrating how to use the OpenAI Chat Completions API to enforce structured JSON outputs using a specific model. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI Chat Completions API to enforce structured JSON outputs usi... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-nodejs-2.text | A Node.js code example demonstrating how to use the OpenAI API to enforce structured JSON outputs using a specific model. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to use the OpenAI API to enforce structured JSON outputs using a specific mo... |
examples/structured-model-outputs-openai-api-openai-api-structured-outputs-python-3.text | A Python code example demonstrating how to use the OpenAI client to request structured JSON outputs from a model. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client to request structured JSON outputs from a model. |
What This Skill Covers
- class Step(BaseModel): explanation: str output: str
- Main sections:
Refusals with Structured Outputs,Tips and best practices,Handling user-generated input,Handling mistakes,Avoid JSON schema divergence.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.openai.com/api/docs/guides/structured-outputs
