sp-openrouter

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

Updated Jul 30, 2026
One-click install
npx skills add https://github.com/ramizik/okta --skill sp-openrouter-ramizik
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sp-openrouter
Source: https://github.com/ramizik/okta/tree/main/.agents/skills/sp-openrouter
Command: npx skills add https://github.com/ramizik/okta --skill sp-openrouter-ramizik

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Connecting an application to many different AI models normally means juggling multiple provider SDKs, APIs, and authentication schemes. This Skill provides complete guidance for the OpenRouter TypeScript SDK, giving access to 300+ models through one unified, type-safe interface. ## Core Features & Use Cases - Unified callModel API: Generate text, stream responses, and run multi-turn conversations with any supported model through a single function. - Typed Tool System: Define tools with Zod schemas for automatic validation, automatic execution, generator tools, and stop conditions like step limits and cost caps. - Authentication Options: Use API keys for server-side apps or the OAuth PKCE flow for user-facing applications, plus programmatic API key management. - Use Case: Build a chat agent that streams responses from an OpenAI model, calls a weather tool automatically, and stops after 10 turns or $1 in cost — all with a few lines of TypeScript. ## Quick Start Use the OpenRouter skill to write TypeScript code that calls a model with a tool and streams the response text.

Frequently Asked Questions about sp-openrouter

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

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

Install @openrouter/agent, initialize the OpenRouter client with your API key, then call client.callModel with a model identifier like 'openai/gpt-5-nano' and your input. Use result.getText() for the full text or result.getTextStream() for streaming.

How do I add tool calling to OpenRouter callModel?

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 the tools and continues the conversation until a stop condition is met.

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

@openrouter/agent covers agent features like callModel, tools, stop conditions, and streaming. @openrouter/sdk covers platform features like model listing, chat completions, credits, OAuth, and API key management.

Does the OpenRouter SDK support OAuth for user-facing apps?

Yes, it supports the OAuth PKCE flow. Use oAuth.createAuthCode to get an authorization URL, redirect the user, then exchange the returned code with oAuth.exchangeAuthCodeForAPIKey to obtain a user-specific API key.

How do I limit cost or turns in multi-turn OpenRouter conversations?

Pass stop conditions via the stopWhen parameter, such as stepCountIs(10) to cap turns, maxCost(1.00) to cap spending, or hasToolCall('finish') to stop on a specific tool call. Custom stop condition functions are also supported.