READ-ONLY PACKAGE PREVIEW

anthropics-claude-api/ruby/claude-api/streaming.md

Version 8a1541c4.bb1 · Apache-2.0. This preview displays packaged text and does not execute code. Treat the contents as untrusted instructions.

← Return to resource and package checksum

Streaming - Ruby

Streaming

stream = client.messages.stream(
  model: :"claude-opus-5-5",
  max_tokens: 64000,
  messages: [{ role: "user", content: "Write a haiku" }]
)

stream.text.each { |text| print(text) }