Skip to content

Commit 8076eea

Browse files
update Realtime API example for GA version
1 parent 4e88565 commit 8076eea

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,10 @@ from openai import AsyncOpenAI
242242

243243
async def main():
244244
client = AsyncOpenAI()
245-
246245
async with client.realtime.connect(model="gpt-realtime") as connection:
247-
await connection.session.update(session={'modalities': ['text']})
246+
await connection.session.update(
247+
session={"type": "realtime", "output_modalities": ["text"]}
248+
)
248249

249250
await connection.conversation.item.create(
250251
item={
@@ -256,12 +257,10 @@ async def main():
256257
await connection.response.create()
257258

258259
async for event in connection:
259-
if event.type == 'response.text.delta':
260+
if event.type == "response.output_text.delta":
260261
print(event.delta, flush=True, end="")
261-
262-
elif event.type == 'response.text.done':
262+
elif event.type == "response.output_text.done":
263263
print()
264-
265264
elif event.type == "response.done":
266265
break
267266

0 commit comments

Comments
 (0)