OpenRouter
Use OpenRouter as a model provider or render items from its Agent SDK.
Use OpenRouter as a model provider
Add the OpenRouter provider to your AI SDK server.
Configure the model ID and the server-side key. Continue using the same Vercel AI SDK view.
Return that response from your authenticated route. Use the Vercel React recipe unchanged. Validate input and own history/tool policy in your server. See OpenRouter's provider docs.
Agent SDK with native items
For the Agent SDK path, install the tested package.
getItemsStream() sends updated items. Replace each item by ID and keep its original position in the list.
Run this on the server or an existing authenticated application owner; deliver its canonical snapshots to the plain-data React view or an external store. Keep the native conversation state for follow-up runs; the projected UI messages do not replace it.
Tools, usage and cancellation
A completed function_call item means its input is ready, not that execution succeeded. A function_call_output is a separate result. Tool execution and approval policy stay with the Agent SDK/application configuration. Unknown items remain explicit. Reasoning summaries require deliberate classification.
The items stream excludes usage metadata. Use native usage/full-response APIs when your application needs cost or round accounting; do not invent totals from displayed text. Pass cancellation through the native signal and preserve its outcome. See Agent item streaming and stability.