🎓 All Courses | 📚 OpenAI API University Syllabus
Stickipedia University
📋 Study this course on TaskLoco

Structured Outputs guarantees the model returns valid JSON matching your exact schema — no more parsing failures in production.

How to Use Structured Outputs

from pydantic import BaseModel

class MovieReview(BaseModel):
    title: str
    rating: int
    summary: str
    sentiment: Literal["positive", "negative", "neutral"]

response = client.beta.chat.completions.parse(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Review: This film was incredible..."}],
    response_format=MovieReview,
)
review = response.choices[0].message.parsed
print(review.rating)  # guaranteed integer

YouTube • Top 10
OpenAI API University: Structured Outputs — Reliable JSON From the API
Tap to Watch ›
📸
Google Images • Top 10
OpenAI API University: Structured Outputs — Reliable JSON From the API
Tap to View ›

Reference:

Structured outputs documentation

image for linkhttps://en.wikipedia.org/wiki/Special:Search?search=Structured%20Outputs

📚 OpenAI API University — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT