sp-openrouter

Integrates 300+ AI models through the OpenRouter TypeScript SDK callModel pattern.

3|2|Updated Aug 28, 2026
One-click install
npx skills add https://github.com/SumonMSelim/stacksmith --skill sp-openrouter-sumonmselim
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sp-openrouter
Source: https://github.com/SumonMSelim/stacksmith/tree/main/.agents/skills/sp-openrouter
Command: npx skills add https://github.com/SumonMSelim/stacksmith --skill sp-openrouter-sumonmselim

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @openrouter/agent, @openrouter/sdk, zod.

What problem does it solve? Building AI features requires juggling different provider APIs, authentication schemes, and message formats. This Skill provides complete guidance for integrating OpenRouter's unified API, giving access to 300+ AI models through a single type-safe TypeScript interface. ## Core Features & Use Cases - Unified Model Access: Use the callModel pattern for text generation, streaming, and multi-turn conversations across 300+ models from one SDK. - Tool System: Define strongly-typed tools with Zod schemas, automatic execution, generator tools, and stop conditions like stepCountIs and maxCost. - Authentication Options: Supports API key authentication for server-side apps and OAuth PKCE flow for user-facing applications. - Use Case: Build a Next.js chat feature that streams responses from openai/gpt-5-nano, executes a weather tool automatically, and stops after 10 turns or a $1 cost limit. ## Quick Start Set up an OpenRouter client with my API key and write a callModel call that streams a response from a free model.

Frequently Asked Questions about sp-openrouter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call AI models with the OpenRouter TypeScript SDK?

Install @openrouter/agent, initialize the OpenRouter client with your API key, and use callModel with a model name and input. The result object provides getText, getResponse, and getTextStream methods for consuming output.

How to add tool calling to OpenRouter callModel requests?

Define tools with the tool() function using Zod schemas for input and output validation, then pass them in the tools array of callModel. The SDK automatically executes tools and continues the conversation until stop conditions are met.

Does OpenRouter SDK support streaming responses?

Yes, the SDK supports streaming via getTextStream for text deltas, getReasoningStream for reasoning tokens, and getToolCallsStream for tool calls. Multiple consumers can read from a single result object concurrently.

What is the difference between @openrouter/agent and @openrouter/sdk?

@openrouter/agent provides agent features like callModel, tool definitions, and stop conditions. @openrouter/sdk covers platform features including model listing, credits, OAuth flows, and API key management.

How do I authenticate users with OpenRouter OAuth?

Use oAuth.createAuthCode with your callback URL to get an authorization URL, redirect the user, then exchange the returned code via exchangeAuthCodeForAPIKey. Store the user's API key securely for their subsequent requests.