Prompt Buddy logoPrompt Buddy

openai · OpenAI Platform Docs

Structured model outputs

Teaches how to implement and manage reliable JSON responses using Structured Outputs, including schema definition via Pydantic or Zod, handling model refusals, and choosing between function calling and response format.

Import to Prompt Buddy

Derived skill

Files assembled from official documentation

Viewing SKILL.md

Structured model outputs

Teaches how to implement and manage reliable JSON responses using Structured Outputs, including schema definition via Pydantic or Zod, handling model refusals, and choosing between function calling and response format.

When To Use

Use when you need to ensure model responses strictly adhere to a predefined JSON schema for type-safe application integration or UI rendering.

Reference Files

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/structured-model-outputs-workflow-guide.mdA guide explaining how to implement structured model outputs using text.format, including examples for data extraction and handling user-generated input.Questions about a guide explaining how to implement structured model outputs using text.format, including examples for data extractio...
examples/structured-model-outputs-openai-structured-outputs-python-pydantic-math-.pythonA Python example using Pydantic models and the chat completions parse method to enforce structured math reasoning outputs.Exact payloads, commands, or snippets shown in A Python example using Pydantic models and the chat completions parse method to enforce structured math reasoning out...
examples/structured-model-outputs-openai-structured-outputs-python-pydantic-math--2.pythonA Python example using Pydantic models and the OpenAI client to enforce structured math reasoning responses.Exact payloads, commands, or snippets shown in A Python example using Pydantic models and the OpenAI client to enforce structured math reasoning responses.

What This Skill Covers

  • How to use Structured Outputs with text.format
  • Main sections: Examples, Handling user-generated input, Handling mistakes, Avoid JSON schema divergence, Streaming.

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.md