Skip to content

docs(readme): fix Nested params example to call existing chat.completions.create#3266

Open
kiwigitops wants to merge 1 commit into
openai:mainfrom
kiwigitops:docs/readme-nested-params-example
Open

docs(readme): fix Nested params example to call existing chat.completions.create#3266
kiwigitops wants to merge 1 commit into
openai:mainfrom
kiwigitops:docs/readme-nested-params-example

Conversation

@kiwigitops
Copy link
Copy Markdown

Fixes #3264.

The "Nested params" example in README.md called client.chat.responses.create(...), which doesn't exist — Chat only exposes completions, so the snippet raised AttributeError: 'Chat' object has no attribute 'responses'. The example also mixed Responses-API parameter shape (input=[...]) with the Chat Completions parameter response_format, so it wouldn't work as a Responses example either.

This change rewrites the snippet as a real Chat Completions call, preserving response_format (which is valid there) so the "nested params are dictionaries, typed using TypedDict" point still lands.

-response = client.chat.responses.create(
-    input=[
-        {
-            "role": "user",
-            "content": "How much ?",
-        }
-    ],
-    model="gpt-5.2",
-    response_format={"type": "json_object"},
-)
+response = client.chat.completions.create(
+    messages=[
+        {
+            "role": "user",
+            "content": "Can you generate an example json object describing a fruit?",
+        }
+    ],
+    model="gpt-5.2",
+    response_format={"type": "json_object"},
+)

@kiwigitops kiwigitops requested a review from a team as a code owner May 18, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

README "Nested params" example calls non-existent client.chat.responses.create and mixes two API surfaces

1 participant