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/PhongCT1105/okta_stripe_hack --skill sp-openrouter-phongct1105
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sp-openrouter
Source: https://github.com/PhongCT1105/okta_stripe_hack/tree/main/.agents/skills/sp-openrouter
Command: npx skills add https://github.com/PhongCT1105/okta_stripe_hack --skill sp-openrouter-phongct1105

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Building AI features that depend on a single model provider creates vendor lock-in and forces you to maintain separate SDKs for each model. This Skill provides complete guidance for accessing 300+ AI models through OpenRouter's unified TypeScript SDK with one type-safe interface. ## Core Features & Use Cases - Unified Model Access: Call any of 300+ models (OpenAI, Anthropic, and more) through the callModel pattern with text, streaming, and structured responses. - Tool System & Agents: Define strongly-typed tools with Zod schemas, automatic tool execution, multi-turn conversations, and stop conditions like step limits and cost caps. - Authentication Options: Use API keys for server-side apps or the OAuth PKCE flow so end users control their own keys. - Use Case: Build an accountability agent in a Next.js app that generates challenges and evaluates proof submissions, streaming responses to users while capping per-request cost with maxCost stop conditions. ## Quick Start Install @openrouter/agent, set your OPENROUTER_API_KEY environment variable, and ask the agent to generate a callModel request against a model like openai/gpt-5-nano.

Frequently Asked Questions about sp-openrouter

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

FAQPage Schema
How do I call OpenRouter models from TypeScript?

Install @openrouter/agent, initialize the OpenRouter client with your API key, and use callModel with a model identifier like openai/gpt-5-nano and your input. Await result.getText() for the complete response or getTextStream() for streaming.

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

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

How do I add tool calling to an OpenRouter agent?

Define tools with the tool() function using Zod schemas for input and output validation, then pass them to callModel via the tools array. The SDK automatically executes tools and continues the conversation until a stop condition is met.

Does OpenRouter support OAuth for user-facing applications?

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

How do I limit agent cost or turn count in OpenRouter?

Use stop conditions in the stopWhen parameter: stepCountIs(n) caps turns, maxCost(amount) stops when spending exceeds a dollar limit, and hasToolCall(name) stops when a specific tool is invoked. Custom stop functions are also supported.

Can I convert OpenAI or Claude message formats for OpenRouter?

Yes, the SDK includes format converters. Use fromChatMessages and toChatMessage for OpenAI format, and fromClaudeMessages and toClaudeMessage for Anthropic Claude format, enabling interoperability between ecosystems.