Skip to content

docs: fix incorrect API call in Nested params README example#3278

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

docs: fix incorrect API call in Nested params README example#3278
pintaste wants to merge 1 commit into
openai:mainfrom
pintaste:fix/readme-nested-params-example

Conversation

@pintaste
Copy link
Copy Markdown

Problem

The "Nested params" section in README.md references a non-existent API method client.chat.responses.create and mixes two incompatible API surfaces:

  • client.chat.responses does not exist — Chat only exposes completions (see src/openai/resources/chat/chat.py)
  • input=[...] is the Responses API parameter shape
  • response_format={"type": "json_object"} is a Chat Completions parameter
  • gpt-5.2 is not a real model name

Running the snippet raises AttributeError: 'Chat' object has no attribute 'responses'.

Fix

Switch to client.chat.completions.create with the correct messages= parameter name, a meaningful prompt, and a real model name (gpt-4o).

-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-4o",
+    response_format={"type": "json_object"},
+)

Fixes #3264

The "Nested params" example called `client.chat.responses.create` with
an `input=` parameter, mixing two incompatible API surfaces:
- `client.chat.responses` does not exist (`Chat` only exposes `completions`)
- `input=[...]` is the Responses API shape, but `response_format` is a
  Chat Completions parameter

Fix by switching to `client.chat.completions.create` with the correct
`messages=` parameter name and a real model name (`gpt-4o`).

Fixes openai#3264
@pintaste pintaste requested a review from a team as a code owner May 19, 2026 22:09
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