Skip to content

Commit f20121b

Browse files
authored
Update OpenAI example to use Responses API (#5)
Switch from chat.completions to responses API for compatibility with latest OpenAI models (GPT 5.1, CODEX-MAX, etc.)
1 parent 7123e34 commit f20121b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ Let's start with the first step. Click on the tabs to find the right LM for you.
7474
) # or set OPENAI_API_KEY env var
7575

7676
def query_lm(messages):
77-
response = client.chat.completions.create(
77+
response = client.responses.create(
7878
model="gpt-5.1",
79-
messages=messages
79+
input=messages
8080
)
81-
return response.choices[0].message.content
81+
return response.output_text
8282
```
8383

8484
=== "Anthropic"

0 commit comments

Comments
 (0)