ruby/index.md +27 −0
50end50end
51```51```
52 52
53### Realtime WebSockets
54
55The SDK supports block-scoped, typed Realtime WebSocket sessions for
56server-side text workflows. Add the optional `async-websocket` gem, then use
57`client.realtime.connect`:
58
59```ruby
60client.realtime.connect(model: "gpt-realtime-2.1") do |connection|
61 connection.session.update(type: :realtime, output_modalities: [:text])
62 connection.conversation.items.create(
63 type: :message,
64 role: :user,
65 content: [{type: :input_text, text: "Hello"}]
66 )
67 connection.response.create
68
69 connection.each do |event|
70 print(event.delta) if event.is_a?(OpenAI::Realtime::ResponseTextDeltaEvent)
71 break if event.is_a?(OpenAI::Realtime::ResponseDoneEvent)
72 end
73end
74```
75
76See the [Realtime WebSocket guide](realtime.md) and the runnable
77[text example](examples/realtime/README.md) for lifecycle, authentication,
78proxy, TLS, and custom transport details.
79
53### Pagination80### Pagination
54 81
55List methods in the OpenAI API are paginated.82List methods in the OpenAI API are paginated.