Learning resourcesReviewed · OpenRouter

OpenRouter Agent SDK: Working with Items

Working with Items is an OpenRouter Agent SDK guide for developers building streaming AI interfaces, but its React example needs additional application code before use. It explains replacing streamed items by ID, handling different output types and migrating to getItemsStream().

Researched 13 Nov 2026

In short.

Working with Items is a guide for developers integrating OpenRouter model streams into applications, but its examples are incomplete and have not been executed. Its central rule is to replace each stored item when an updated item with the same ID arrives. The page covers text, reasoning and tool-related output, illustrates React state management, and explains migration from getNewMessagesStream(). Package installation, pricing, licensing and model-specific support are not established.

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

Coverage includes the complete selected page at [https://openrouter.ai/docs/agent-sdk/call-model/items.md], including its deprecation notice, examples and linked-document references. The documentation index and all linked pages are excluded. No package or repository contents were supplied, and no code, model calls, compatibility checks or performance tests were executed.

The overview

Identity

Working with Items documents the items-based streaming interface for callModel in the OpenRouter Agent SDK. The page says callModel uses OpenRouter's Responses API and demonstrates imports from @openrouter/agent. Original source: [https://openrouter.ai/docs/agent-sdk/call-model/items.md].

Assessment

The guide provides a concrete explanation of an easy streaming mistake: appending text when an update already contains the item's current content. Its successive message snapshots and Map-based React example make the replacement rule understandable.

It is useful for learning the streaming contract, but it does not provide a complete application or establish reliability, performance or compatibility through execution.

Users

The clearest audience is TypeScript and React developers displaying generated text alongside reasoning or tool activity. Developers moving from chunk-based streaming or the older getNewMessagesStream() method also receive directly relevant examples.

Beginners can follow the message snapshots, but implementing the examples requires familiarity with asynchronous iteration, React state and rendering components. This page does not teach those prerequisites.

Capabilities

The page lists seven output types: message, function_call, reasoning, web_search_call, file_search_call, image_generation_call and function_call_output. It explains how getItemsStream() exposes these categories, whereas the deprecated getNewMessagesStream() surfaced only messages.

It also describes concurrent item updates, React 18+ compatibility and TypeScript inference. These are documentation claims; model-specific availability and runtime behavior have not been assessed.

Using it

Requirements

The example uses OpenRouter and StreamableOutputItem from @openrouter/agent, an API key read from OPENROUTER_API_KEY, and a model identifier passed to callModel. Its interface example uses React state and TSX.

The page does not specify an SDK version, installation command, supported runtime versions or account setup. It also does not explain credential handling for a deployed React application.

Mechanism

Each emission is a snapshot of an item's current state. When another snapshot arrives with the same ID, the consumer replaces the previous item. The React example stores items in a Map and creates a new Map for each update so that setting state triggers rendering.

A complete snapshot does not mean generation is finished. The function-call examples contain unfinished JSON arguments in early emissions, followed by a complete argument string later. The page does not document how to detect when those arguments are ready for use.

Setup

The illustrated sequence is to construct an OpenRouter client, call client.callModel with a model and input, then iterate over result.getItemsStream(). For React, initialize a Map of StreamableOutputItem values and replace entries using item.id.

The sample needs an input value and implementations of MessageItem, ToolCallItem and ReasoningItem. Installation, request error handling and deployment configuration are not supplied, so the snippet needs further work before application use.

Example

The message example emits msg_123 three times, progressing from Hello to Hello world to Hello world!. A consumer following the guide keeps one entry for msg_123 and replaces its content on each emission. Concatenating the snapshots would repeat text.

For migration, the page replaces iteration over getNewMessagesStream() with getItemsStream(). Consumers must account for the broader set of item types. These are source examples; no code was executed.

Assessment & evidence

Limitations

The React renderer handles message, function_call and reasoning items, then returns null for other types. Consequently, the displayed example does not render the search, image-generation or function-output item types listed elsewhere on the page.

The function-call snapshots show callId but omit id, leaving the relationship between those identifiers unexplained in those snippets. The page also provides no guidance on cancellation, recovery after a failed stream or separating repeated submissions.

Fit and tradeoffs

The documented approach fits interfaces that must maintain several evolving output objects, such as text and tool activity. Replacing entries by ID gives each object a stable place in application state.

For a display that only needs appended text, the page's getTextStream() example offers a simpler state shape. Neither approach is shown to be faster or more reliable; the useful distinction is how the application represents its output.

Alternatives

Within the page, getTextStream() illustrates text-chunk accumulation, while getItemsStream() preserves typed output objects. The page also compares its approach with OpenAI Chat and Vercel AI SDK message-based streaming, but supplies no complete integrations or independent comparison.

getNewMessagesStream() is explicitly deprecated in favor of getItemsStream(). It is presented as a migration source rather than a recommended alternative.

Evidence

The evidence is the complete selected OpenRouter documentation page, including its conceptual explanation, item-type table, streaming snapshots, React example and migration guidance. It supports an explanation of the documented API pattern.

No SDK implementation, package metadata, execution results or benchmarks are included. Documentation examples alone do not establish production behavior.

Access & freshness

Costs

The page supplies no SDK price, API rates, free allowance or tool charges. The example requests a model through OpenRouter, but its operating cost is unknown from this evidence. No usage or cost measurements are available.

Rights

The supplied page contains no explicit license or redistribution permission for its prose or sample code. The SDK package license is also not established. Rights to redistribute these materials are unknown.

Freshness

The supplied page was captured on 13 November 2026 at 11:44:10.930 UTC. It provides no publication date, update date or SDK version, so its applicability to a particular installed release is unknown.

The example uses ~anthropic/claude-sonnet-latest. The underlying model and version resolved by that alias are not established by the page.

Next steps

Use the guide to implement replacement by item ID and to identify which output types your interface needs to render. Before application use, supply the missing components, establish credential handling, and verify completion handling for streamed function arguments.

Confirm the installed SDK's API, model support, pricing and license separately. The page links to further streaming and tool documentation at [https://openrouter.ai/docs/agent-sdk/call-model/streaming.md] and [https://openrouter.ai/docs/agent-sdk/call-model/tools.md]; their contents have not been assessed.

Evidence for this report

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