| name | openrouter-install-auth |
| description | Set up OpenRouter API authentication and configure API keys. Use when starting a new OpenRouter integration, rotating keys, or troubleshooting auth issues. Triggers: 'openrouter setup', 'openrouter api key', 'configure openrouter auth', 'sk-or key'.
|
| allowed-tools | Read, Write, Edit, Grep, Bash(python3:*), Bash(node:*), Bash(pip:*), Bash(npm:*) |
| version | 1.20.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","openrouter","api","authentication","setup"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
OpenRouter Install & Auth
Overview
Set up OpenRouter API credentials, configure the OpenAI-compatible client, verify authentication, and check credit balance. OpenRouter keys start with sk-or-v1- and authenticate against https://openrouter.ai/api/v1.
Prerequisites
- OpenRouter account (free at openrouter.ai)
- Python 3.8+ or Node.js 18+
- OpenAI SDK (
pip install openai or npm install openai)
Instructions
1. Generate an API Key
- Go to openrouter.ai/keys
- Click Create Key, name it (e.g.,
my-app-dev)
- Copy the
sk-or-v1-... value immediately (shown only once)
- Optionally set a credit limit on the key for spend control
2. Configure Environment
OPENROUTER_API_KEY=sk-or-v1-your-key-here
export OPENROUTER_API_KEY="sk-or-v1-your-key-here"
3. Initialize the Client
Python:
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=os.environ["OPENROUTER_API_KEY"],
default_headers={
"HTTP-Referer": "https://your-app.com",
"X-Title": "Your App Name",
},
)
TypeScript:
import OpenAI from "openai";
const client = new OpenAI({
baseURL: ,
: process..,
: {
: ,
: ,
},
});