Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/structured-model-outputs-openai-api-workflow-guide.mdA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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