OpenRouter
Choose a model provider or the Agent SDK; keep the UI independent of that choice.
Provider through Vercel AI SDK
Install @openrouter/ai-sdk-provider@3.1.0 on the server with the current AI SDK. This route changes the model provider, not Ghost's runtime. Use your configured model ID and a server-only key.
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
OpenRouter also provides an actual Agent SDK, @openrouter/agent@0.11.0. It is a separate integration path. getItemsStream() emits replacement items, not text deltas; replace the item with the same ID without moving its first position.
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.