From d5f892140ec0600a2e53a6c38ded3108e4f53079 Mon Sep 17 00:00:00 2001 From: Aaron Augustine Date: Sat, 4 Oct 2025 12:11:05 -0400 Subject: [PATCH] fix readme on nested_params for response format --- README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9311b477a3..fcf65e65b5 100644 --- a/README.md +++ b/README.md @@ -373,19 +373,28 @@ Nested parameters are dictionaries, typed using `TypedDict`, for example: ```python from openai import OpenAI +from pydantic import BaseModel client = OpenAI() -response = client.chat.responses.create( +class CalendarEvent(BaseModel): + name: str + date: str + participants: list[str] + +response = client.responses.parse( + model="gpt-4o-2024-08-06", input=[ + {"role": "system", "content": "Extract the event information."}, { "role": "user", - "content": "How much ?", - } + "content": "Alice and Bob are going to a science fair on Friday.", + }, ], - model="gpt-4o", - response_format={"type": "json_object"}, + text_format=CalendarEvent, ) + +event = response.output_parsed ``` ## File uploads