Claude API · Streaming

Stream in TypeScript

Subscribe to text events, then await the final message.

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

stream.on("text", (text) => process.stdout.write(text));
const message = await stream.finalMessage();

Official Claude API documentation

More streaming commands

All streaming commands · Claude API cheatsheet

Was this page helpful?