Openrouter Install Auth
Overview
This skill guides you through obtaining and configuring OpenRouter API credentials, setting up environment variables, and verifying your authentication is working correctly.
Prerequisites
- OpenRouter account (free at openrouter.ai)
- Python 3.8+ or Node.js 18+
- OpenAI SDK installed (
pip install openaiornpm install openai)
Instructions
- Create an OpenRouter account: Sign up at openrouter.ai and navigate to the API Keys page
- Generate an API key: Click "Create Key", give it a descriptive name, and copy the
sk-or-...value immediately (it won't be shown again) - Configure your environment: Add
OPENROUTER_API_KEY=sk-or-...to your.envfile or export it in your shell profile - Initialize the OpenAI SDK: Point the SDK at
base_url="https://openrouter.ai/api/v1"with your key - Verify authentication: Run a minimal chat completion request and confirm you get a 200 response with valid output
Output
- A working OpenAI SDK client configured for OpenRouter
- Environment variable set and loadable from
.env - Successful test request confirming authentication works
Error Handling
| Error | Cause | Fix |
|---|---|---|
401 invalid_api_key |
Key is malformed or revoked | Regenerate at openrouter.ai/keys |
401 missing_api_key |
Authorization header missing | Add Authorization: Bearer sk-or-... header |
403 insufficient_credits |
Account has no credits | Add credits at openrouter.ai/credits or use a free model |
See ${CLAUDE_SKILL_DIR}/references/errors.md for full error reference.
Examples
See ${CLAUDE_SKILL_DIR}/references/examples.md for runnable code samples.