Learning resourcesReviewed · Anthropic

Claude Messages API: Streaming messages

Streaming messages is Anthropic's guide for developers adding live Claude replies to apps, with the catch that partial replies and failures need careful handling. It explains server-sent events, SDK helpers, streamed tool inputs, thinking output and recovery after interruptions.

Researched 25 Nov 2026

In short.

Streaming messages is Anthropic's guide for developers who want Claude replies to appear as they are generated, but applications must still handle incomplete content and failures. It covers SDK helpers and the underlying event protocol, including tool arguments, thinking output and complete-message accumulation. Its examples support planning an integration; runtime compatibility, latency and reliability are unassessed, while prices and reuse rights are unspecified.

Researched and written by an AI model and checked by a second AI model. How it works

Covers the complete captured page at [https://platform.claude.com/docs/en/build-with-claude/streaming.md], including metadata, examples, event definitions, error recovery, beta and fallback notices, next-step links and availability qualifications. Linked pages and SDK repositories are excluded. The Bedrock bedrock-runtime transport exception and limits on recovering tool-use and thinking blocks are material qualifications. No examples were executed; runtime behavior, performance and recovery fidelity remain unassessed, while costs and licensing are unspecified.

The overview

identity

Anthropic's Streaming messages guide documents incremental responses from the Claude Messages API. The source address is [https://platform.claude.com/docs/en/build-with-claude/streaming.md], and its metadata identifies [https://platform.claude.com/docs/en/build-with-claude/streaming] as the documentation URL.

assessment

This is a useful implementation guide for moving from a single completed response to output that arrives in pieces. Its strengths are the combination of approachable text-streaming examples, complete event transcripts and explanations of structured content and failures.

It recommends client SDKs while documenting enough of the HTTP stream for developers building their own integration. It provides no measured performance results, complete production application or independently demonstrated recovery behavior.

users

Developers building chat interfaces can use the text-streaming examples to display an answer progressively. Beginners will need familiarity with API requests, authentication and their chosen programming language; the page does not provide a complete account or SDK installation walkthrough.

Experienced developers building tool-using applications or custom clients will find the block indexes, partial JSON rules, thinking events and recovery differences particularly relevant.

capabilities

The guide covers arriving text, tool arguments, thinking output and server-side web-search events. Examples span cURL, the ant CLI, Python, TypeScript, C#, Go, Java, PHP and Ruby. It states that Python supports synchronous and asynchronous streams.

SDK helpers can collect streamed events into a complete Message without requiring the application to process each event manually. The page distinguishes summarized thinking, omitted thinking text and beta progress updates. Thinking display settings determine which thinking text is emitted; signature data is delivered separately.

Using it

requirements

The direct Claude API examples require an API key, a model, messages, an output-token limit and a client capable of reading a persistent HTTP response. They use the anthropic-version header value 2026-10-21. Required SDK package versions and runtime versions are unspecified.

The page states that streaming is available on every model and lists Claude API, Amazon Bedrock, Claude Platform on AWS, both listed Google Cloud variants and Microsoft Foundry. Amazon Bedrock's bedrock-runtime endpoint has a transport exception: it does not deliver plain server-sent events. Detailed provider setup is outside this page.

mechanism

Setting stream to true makes the API send server-sent events, which are named updates carrying JSON data over an open HTTP connection. A normal response starts with message_start, contains indexed content blocks with start, delta and stop events, then sends message_delta updates and ends with message_stop. Ping events may appear between updates.

A delta is a piece of an update. Text deltas contain text fragments; input_json_delta contains partial JSON strings that eventually form a tool-input object. Raw clients can concatenate those strings and parse them when the block stops. Python and TypeScript helpers also expose incrementally parsed input.

Some blocks arrive complete without deltas, including redacted thinking, server tool results and fallback blocks. Optional beta controls can add input_transformations metadata, including an update after server-side fallback. These cases require more than a text-only event handler.

setup

For a first integration, follow the example for your SDK: create a client, supply a model, messages and max_tokens, open a stream and consume arriving text. The Python example uses client.messages.stream() and stream.text_stream. Raw HTTP requests additionally set stream to true.

If the application only needs a completed answer, Python's get_final_message() and TypeScript's finalMessage() accumulate the stream into a Message. The page explains that streaming can be required by SDKs for large max_tokens requests to avoid HTTP timeouts, but gives no universal threshold. The CLI emits individual events and does not perform this final-message accumulation.

example

The basic example sends Hello to claude-opus-5-5 with max_tokens set to 256. Its illustrated response opens a text block, delivers Hello and an exclamation mark in separate deltas, closes the block and finishes with an end_turn stop reason. This demonstrates event assembly; it supplies no measured timing result.

The weather-tool example illustrates a tool_use block whose streamed JSON fragments form a location argument, followed by a tool_use stop reason. A working get_weather implementation is not supplied. Applications needing these arguments must process tool events in addition to text.

Assessment & evidence

limitations

A stream can fail after output has started. The API can emit an error event such as overloaded_error; SDK readers instead receive an error when the SDK ends the stream. Applications must also handle unknown event types gracefully because new types may be added.

Recovery requires saving partial content and making a continuation request. For Claude 4.5 and earlier, the guide places partial output in an assistant message. For Claude 4.6 and later, it places the partial response and a continuation instruction in a user message. Tool-use and thinking blocks cannot be partially recovered; recovery can resume from the most recent text block. Continuation fidelity is unassessed.

By default, tool input keys and values are buffered until complete, so pauses between events are possible. The page names eager_input_streaming for finer tool-parameter delivery, but its detailed operation is covered by a linked guide. Thinking progress updates are also marked beta.

reasoning

The guide's practical value comes from covering both simple text display and the structured events needed for tool use. Developers can begin with SDK text helpers and use event iteration when their application needs tool arguments, thinking output or message metadata.

Its timeout discussion also explains why streaming may help an application that waits to display one completed answer. The page supplies no benchmark establishing faster total generation, a particular time to first text or a reliability improvement.

alternatives

The page identifies ordinary message creation as another way to obtain a completed Message. Streaming with an accumulation helper preserves that completed-message interface while consuming events internally. Direct HTTP event handling offers control over parsing but requires implementing the documented event lifecycle.

For workloads without real-time response requirements, the page points to batch processing. That linked guide and competing providers are outside the evidence, so their costs, performance and suitability are not compared.

evidence

The evidence is the complete captured Streaming messages page at [https://platform.claude.com/docs/en/build-with-claude/streaming.md]. It contains feature metadata, SDK and HTTP examples, event definitions, recovery guidance and an availability table.

The request and response sequences are documentation illustrations. No code or API request was executed. Linked SDK repositories, error references, thinking guides and provider documentation were not assessed.

Access & freshness

costs

The page specifies no API prices, streaming surcharge policy, tool prices or worked monetary costs. Actual costs are unknown.

The examples include usage fields, and the page warns that token counts in message_delta usage are cumulative. Summing successive cumulative counts can overcount usage. Example token counts do not establish the cost of another request.

rights

The page contains no explicit licence or redistribution grant for the documentation or sample code. It links to SDK repositories, but their licence terms are outside the supplied evidence. Reuse and redistribution rights are therefore unknown from this page.

freshness

The page was captured on 25 November 2026 at 08:22:54.329 UTC. Its metadata labels streaming stable, and its HTTP examples use API version 2026-10-21. A page publication date, last-update date and SDK package versions are not supplied.

Model names, beta controls, SDK helpers and platform availability describe this captured version. Their status after capture is unknown.

actions

Choose an SDK example matching your language and decide whether the interface needs arriving text or only a final Message. For tool-using applications, plan separate handling for text, tool-input fragments and completed content blocks.

Before relying on the integration, verify stream completion, cumulative usage accounting, errors after partial output and recovery for the chosen model generation. Confirm the provider's transport, current SDK requirements, prices and applicable reuse terms. These remain implementation and verification steps.

Evidence for this report

selected-page.txtselected · checked 2026-11-25