Learning resourcesReviewed · OpenRouter

OpenRouter Agent SDK Streaming Guide

OpenRouter’s streaming guide teaches JavaScript and TypeScript developers how to display AI responses as they arrive, but its examples leave installation and error recovery unexplained. It covers text chunks, reasoning output, structured items, tool progress, concurrent consumers and cancellation through @openrouter/agent.

Researched 14 Nov 2026

In short.

OpenRouter’s streaming guide is a reference for developers building live AI interfaces, but its snippets leave SDK versions, pricing and production error handling unspecified. Its central distinction is between appending text chunks and replacing complete output items by ID. It also documents tool events, concurrent consumers, cancellation and React/SSE examples. getNewMessagesStream() is explicitly deprecated in favor of getItemsStream(). No examples were executed, and runtime behavior, compatibility and performance remain unverified.

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

Coverage is limited to the complete selected page at [https://openrouter.ai/docs/agent-sdk/call-model/streaming.md], including its stream methods, item and event tables, deprecation notice, concurrent-consumer example, cancellation example and React/SSE snippets. The linked documentation index, Working with Items page and Tools page are excluded. No code was executed. Installation, live model availability, runtime compatibility, security of a deployed integration, performance, costs and cancellation behavior remain unverified or unspecified.

The overview

identity

This is the Streaming documentation for OpenRouter’s Agent SDK. It explains how to consume results from callModel() using the @openrouter/agent package. The original-source page is [https://openrouter.ai/docs/agent-sdk/call-model/streaming.md].

The resource is a focused API guide with TypeScript and React examples. Installation instructions, tool definitions and the broader items-based programming model are not fully explained on this page.

assessment

The guide is useful for choosing how an application should receive AI output: simple text chunks, structured output items or detailed response events. Its most consequential implementation advice is to replace updated items by ID instead of concatenating them.

Short examples make individual methods approachable, while tool events and concurrent consumption provide useful detail for experienced developers. The page does not establish that these snippets form a complete, deployable integration.

users

The material suits developers adding live responses to chat interfaces, displaying agent tool activity or forwarding model output through a server endpoint. React and Hono examples connect the stream APIs to interface and server code.

The examples assume familiarity with imports, asynchronous iteration, promises and API credentials. Beginners may need additional instruction on those concepts and on configuring an application before adapting the snippets.

capabilities

The page documents getTextStream() for text chunks, getReasoningStream() for supported reasoning output, getItemsStream() for updated structured items and getFullResponsesStream() for detailed events. getToolCallsStream() delivers structured calls as they complete, while getToolStream() exposes argument deltas and preliminary tool results.

Listed item categories include messages, function calls, reasoning, web search, file search, image generation and function-call outputs. Listing these categories does not establish that every model supports each one. The guide also describes concurrent consumers and cancellation through result.cancel().

Using it

requirements

The initial example imports OpenRouter from @openrouter/agent and supplies an API key through process.env.OPENROUTER_API_KEY. Applications need an environment that supports the illustrated asynchronous JavaScript patterns and access to the chosen model.

Tool examples reference definitions such as myTool, searchTool and weatherTool without supplying their implementations. The framework examples additionally use React or Hono. Required package versions, runtime versions and model access conditions are unknown from this page.

mechanism

getTextStream() yields small text additions that an application can append. getItemsStream() instead yields complete items whose content changes while their IDs remain stable; an application should update the stored item with that ID.

The underlying ReusableReadableStream is documented as delivering all events to each concurrent consumer. An example combines text collection with getResponse() through Promise.all. Buffering limits and memory behavior are not specified.

The full event stream distinguishes text and argument deltas, completion events, preliminary tool progress and final tool results. In the structured tool-call example, maxToolRounds: 0 disables automatic tool execution so the application can receive the calls.

setup

The demonstrated sequence is to construct an OpenRouter client with credentials, call callModel() with a model and input, and consume the chosen stream using for await. The page supplies no package installation command or complete project configuration.

The React example updates component state with arriving text and cancels the result during effect cleanup. The Hono example forwards text as SSE delta events and sends a done event afterward. The React sample constructs the client with API_KEY inside the component; secure browser credential handling is not explained.

example

The opening example requests an ocean poem from openai/gpt-5-nano and writes each getTextStream() chunk to standard output. A chat interface could apply the same append-as-chunks-arrive pattern to its displayed response.

For a richer interface, the items example branches on message, function_call, reasoning and function_call_output. Each update should replace the matching item by ID. These are documented examples; no generated response, timing result or successful execution was observed.

Assessment & evidence

limitations

The snippets do not demonstrate exception handling, retries, buffering limits or recovery from interrupted connections. The cancellation example stops after a character threshold, but cancellation timing and its interaction with active tools are not explained.

Reasoning output depends on model support. The listed output types and named example models do not establish universal compatibility. No latency, throughput, memory, reliability or cross-provider measurements are supplied.

getNewMessagesStream() is explicitly deprecated. Its example remains on the page, alongside the instruction to use getItemsStream() instead.

reasoning

The guide’s practical value comes from explaining what each stream update represents. Appending text deltas suits a text display; replacing complete items by ID suits a display containing messages, tool calls and tool results. Mixing those rules could duplicate content.

The reasoning stream exposes model-provided reasoning output where supported, while the items example reads a reasoning summary. The page does not establish that either output is a complete or faithful account of internal model computation, or that displaying it improves answer accuracy.

alternatives

Within the documented SDK, getTextStream() is the simplest option for text-only display. getItemsStream() provides structured access across output categories, while getFullResponsesStream() exposes more detailed events, including tool progress.

Applications needing only completed structured tool calls can consider getToolCallsStream(); those needing argument deltas and preliminary results can consider getToolStream(). Other SDKs, direct provider APIs and competing streaming approaches are not assessed in this page.

evidence

The evidence consists of the complete captured Streaming documentation page at [https://openrouter.ai/docs/agent-sdk/call-model/streaming.md]. It supports descriptions of the documented APIs, examples, event types and deprecation notice.

The page links to a documentation index and separate Working with Items and Tools pages. Those linked materials are outside this assessment. No SDK source, execution logs, independent measurements or deployment evidence were supplied.

Access & freshness

costs

The page provides no prices, free-tier terms, subscription requirements or billing rules. Model usage costs and any other required service charges are unknown.

The concurrent-consumer example accesses response.usage, but it supplies no usage values or conversion to money. The page also does not explain how cancellation affects billing or whether concurrent consumption changes charges.

rights

This page includes no explicit licence or redistribution permission for its documentation, examples or SDK. Commercial reuse permissions, service terms and rights governing model outputs are not established by the supplied text.

freshness

The available page snapshot was captured on 2026-11-14 at 11:50:42.540 UTC. The text supplies no publication date, update date or SDK package version.

Examples name openai/gpt-5-nano, openai/o3 and ~anthropic/claude-sonnet-latest. Their current availability and compatibility are not established. The captured text identifies getNewMessagesStream() as deprecated, but subsequent API changes are unknown.

actions

Confirm that the installed SDK version and chosen model support the required streams. Use getItemsStream() when an interface needs mixed output types, retain items by ID, and replace the deprecated getNewMessagesStream() in new adaptations.

Before deployment, resolve credential placement, supply actual tool definitions, add error handling and connect cancellation to interface or connection cleanup. Check pricing and applicable terms separately, and measure concurrent-consumer behavior and cancellation under the intended workload; those results remain unknown.

Evidence for this report

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