Add interactive model selection to OpenRouter skill
- Ask user which OpenRouter model they want to use - Provide link to OpenRouter model catalog (https://openrouter.ai/models) - Guide users to browse, click, and copy model name - Store selected model in ~/.claude/settings.json - Add popular model recommendations table - Document model change process (3 options) - Add model-specific troubleshooting (model not found, context length) - Expand supported models section with examples from multiple providers - Include free tier models (meta-llama with :free suffix) - Add model name accuracy notes (suffixes like :beta, :free) - Update example commands to include model selection scenarios
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# OpenRouter Config Skill
|
# OpenRouter Config Skill
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
This skill helps users configure and enable OpenRouter as the AI provider in Claude Code. It sets up the OpenRouter API key, configures the Anthropic-compatible API endpoints, and ensures Claude Code uses OpenRouter exclusively with proper failover capabilities.
|
This skill helps users configure and enable OpenRouter as the AI provider in Claude Code. It allows you to select your preferred OpenRouter model, sets up the API key, configures Anthropic-compatible API endpoints, and ensures Claude Code uses OpenRouter exclusively with proper failover capabilities.
|
||||||
|
|
||||||
## Documentation Source
|
## Documentation Source
|
||||||
Based on official OpenRouter documentation: https://openrouter.ai/docs/guides/claude-code-integration
|
Based on official OpenRouter documentation: https://openrouter.ai/docs/guides/claude-code-integration
|
||||||
@@ -11,24 +11,64 @@ Based on official OpenRouter documentation: https://openrouter.ai/docs/guides/cl
|
|||||||
### 1. Provider Failover for High Availability
|
### 1. Provider Failover for High Availability
|
||||||
Anthropic's API occasionally experiences outages or rate limiting. When you route Claude Code through OpenRouter, your requests automatically fail over between multiple Anthropic providers. If one provider is unavailable or rate-limited, OpenRouter seamlessly routes to another, keeping your coding sessions uninterrupted.
|
Anthropic's API occasionally experiences outages or rate limiting. When you route Claude Code through OpenRouter, your requests automatically fail over between multiple Anthropic providers. If one provider is unavailable or rate-limited, OpenRouter seamlessly routes to another, keeping your coding sessions uninterrupted.
|
||||||
|
|
||||||
### 2. Organizational Budget Controls
|
### 2. Access to 100+ Models
|
||||||
|
OpenRouter gives you access to models from multiple providers including:
|
||||||
|
- **Anthropic**: Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku
|
||||||
|
- **OpenAI**: GPT-4, GPT-4 Turbo, GPT-3.5
|
||||||
|
- **Google**: Gemini Pro, Gemini Flash
|
||||||
|
- **Meta**: Llama 2, Llama 3
|
||||||
|
- **Mistral**: Mixtral, Mistral Large
|
||||||
|
- **And many more**: xAI, Perplexity, Cohere, etc.
|
||||||
|
|
||||||
|
### 3. Organizational Budget Controls
|
||||||
For teams and organizations, OpenRouter provides centralized budget management. You can set spending limits, allocate credits across team members, and prevent unexpected cost overruns.
|
For teams and organizations, OpenRouter provides centralized budget management. You can set spending limits, allocate credits across team members, and prevent unexpected cost overruns.
|
||||||
|
|
||||||
### 3. Usage Visibility and Analytics
|
### 4. Usage Visibility and Analytics
|
||||||
OpenRouter gives you complete visibility into how Claude Code is being used across your team. Track usage patterns, monitor costs in real-time, and understand which projects or team members are consuming the most resources. All of this data is available in your [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity).
|
OpenRouter gives you complete visibility into how Claude Code is being used across your team. Track usage patterns, monitor costs in real-time, and understand which projects or team members are consuming the most resources. All of this data is available in your [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity).
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
To use this skill, simply ask Claude Code to configure OpenRouter. The skill will:
|
To use this skill, simply ask Claude Code to configure OpenRouter. The skill will:
|
||||||
1. Set up your OpenRouter API key
|
|
||||||
2. Configure the Anthropic-compatible environment variables
|
1. **Ask you which OpenRouter model you want to use**
|
||||||
3. Ensure Claude Code uses OpenRouter exclusively
|
2. Provide a link to browse available models
|
||||||
4. Set up proper provider priority (Anthropic 1P)
|
3. Guide you to copy the model name from OpenRouter's model catalog
|
||||||
5. Verify the configuration is working
|
4. Set up your OpenRouter API key
|
||||||
|
5. Configure Anthropic-compatible environment variables
|
||||||
|
6. Ensure Claude Code uses OpenRouter exclusively
|
||||||
|
7. Set up proper provider priority
|
||||||
|
8. Verify the configuration is working
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
- An OpenRouter API key (get one from https://openrouter.ai/keys)
|
- An OpenRouter API key (get one from https://openrouter.ai/keys)
|
||||||
- Claude Code installed
|
- Claude Code installed
|
||||||
|
|
||||||
|
## Model Selection
|
||||||
|
|
||||||
|
### Step 1: Browse Available Models
|
||||||
|
Visit the OpenRouter models catalog to choose your preferred model:
|
||||||
|
- **OpenRouter Models**: https://openrouter.ai/models
|
||||||
|
|
||||||
|
### Step 2: Find and Copy Your Model
|
||||||
|
Browse through the available models and click on any model to see:
|
||||||
|
- Model name (click to copy)
|
||||||
|
- Pricing (input/output tokens)
|
||||||
|
- Context length
|
||||||
|
- Features (function calling, vision, etc.)
|
||||||
|
- Provider information
|
||||||
|
|
||||||
|
**Popular Model Examples:**
|
||||||
|
| Model | Provider | Best For |
|
||||||
|
|-------|----------|----------|
|
||||||
|
| `anthropic/claude-3.5-sonnet` | Anthropic | General coding, reasoning |
|
||||||
|
| `anthropic/claude-3.5-sonnet:beta` | Anthropic | Latest Claude features |
|
||||||
|
| `openai/gpt-4-turbo` | OpenAI | Fast, cost-effective |
|
||||||
|
| `google/gemini-pro-1.5` | Google | Long context |
|
||||||
|
| `meta-llama/llama-3.1-70b-instruct:free` | Meta | Free tier available |
|
||||||
|
| `mistralai/mistral-large` | Mistral | Multilingual |
|
||||||
|
|
||||||
|
### Step 3: Configure Your Chosen Model
|
||||||
|
The skill will ask you to paste the model name you selected. You can also change the model later by editing your Claude Code settings.
|
||||||
|
|
||||||
## Configuration Steps
|
## Configuration Steps
|
||||||
|
|
||||||
### Step 1: Install Claude Code (if not already installed)
|
### Step 1: Install Claude Code (if not already installed)
|
||||||
@@ -56,13 +96,26 @@ export ANTHROPIC_API_KEY="" # Important: Must be explicitly empty
|
|||||||
- **Must explicitly blank out** `ANTHROPIC_API_KEY` to prevent conflicts
|
- **Must explicitly blank out** `ANTHROPIC_API_KEY` to prevent conflicts
|
||||||
- If previously logged in to Claude Code with Anthropic, run `/logout` in a Claude Code session to clear cached credentials
|
- If previously logged in to Claude Code with Anthropic, run `/logout` in a Claude Code session to clear cached credentials
|
||||||
|
|
||||||
### Step 3: Start Claude Code
|
### Step 3: Configure Your Model
|
||||||
|
The skill will add your chosen model to your Claude Code settings at `~/.claude/settings.json`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"provider": {
|
||||||
|
"baseUrl": "https://openrouter.ai/api",
|
||||||
|
"apiKey": "${ANTHROPIC_AUTH_TOKEN}",
|
||||||
|
"defaultModel": "your-chosen-model-name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 4: Start Claude Code
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/your/project
|
cd /path/to/your/project
|
||||||
claude
|
claude
|
||||||
```
|
```
|
||||||
|
|
||||||
### Step 4: Verify Configuration
|
### Step 5: Verify Configuration
|
||||||
Run the `/status` command inside Claude Code:
|
Run the `/status` command inside Claude Code:
|
||||||
```
|
```
|
||||||
/status
|
/status
|
||||||
@@ -86,17 +139,30 @@ https://openrouter.ai/api
|
|||||||
### Authentication
|
### Authentication
|
||||||
Use your OpenRouter API key as the auth token.
|
Use your OpenRouter API key as the auth token.
|
||||||
|
|
||||||
|
### Model Selection
|
||||||
|
Choose your model from the OpenRouter model catalog:
|
||||||
|
- **Browse Models**: https://openrouter.ai/models
|
||||||
|
- Click on any model to see details and copy the model name
|
||||||
|
- Paste the model name when prompted by this skill
|
||||||
|
|
||||||
### Provider Priority
|
### Provider Priority
|
||||||
**Important**: Claude Code with OpenRouter is only guaranteed to work with the Anthropic first-party provider. For maximum compatibility, we recommend setting **Anthropic 1P** as the top priority provider when using Claude Code.
|
**Important**: Claude Code with OpenRouter is only guaranteed to work with the Anthropic first-party provider. For maximum compatibility, we recommend setting **Anthropic 1P** as the top priority provider when using Claude Code.
|
||||||
|
|
||||||
## Supported Models
|
## Supported Models
|
||||||
|
|
||||||
When using Claude Code through OpenRouter, you can access Anthropic models including:
|
OpenRouter supports 100+ models from various providers. Browse the full catalog:
|
||||||
- Claude 3.5 Sonnet
|
- **OpenRouter Models**: https://openrouter.ai/models
|
||||||
- Claude 3 Opus
|
|
||||||
- Claude 3 Haiku
|
|
||||||
|
|
||||||
The specific model used depends on your Claude Code configuration and can be set via OpenRouter's model routing settings.
|
**Popular Anthropic Models:**
|
||||||
|
- `anthropic/claude-3.5-sonnet` - Latest, most capable
|
||||||
|
- `anthropic/claude-3-opus` - Best for complex tasks
|
||||||
|
- `anthropic/claude-3-haiku` - Fast, cost-effective
|
||||||
|
|
||||||
|
**Popular Alternative Models:**
|
||||||
|
- `openai/gpt-4-turbo` - GPT-4 with Turbo speed
|
||||||
|
- `google/gemini-pro-1.5` - Long context (up to 1M tokens)
|
||||||
|
- `meta-llama/llama-3.1-70b-instruct:free` - Free Llama 3 model
|
||||||
|
- `mistralai/mistral-large` - Strong multilingual capabilities
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
|
|
||||||
@@ -106,6 +172,9 @@ When you set `ANTHROPIC_BASE_URL` to `https://openrouter.ai/api`, Claude Code sp
|
|||||||
### Anthropic Skin
|
### Anthropic Skin
|
||||||
OpenRouter's "Anthropic Skin" behaves exactly like the Anthropic API. It handles model mapping and passes through advanced features like "Thinking" blocks and native tool use.
|
OpenRouter's "Anthropic Skin" behaves exactly like the Anthropic API. It handles model mapping and passes through advanced features like "Thinking" blocks and native tool use.
|
||||||
|
|
||||||
|
### Model Routing
|
||||||
|
When you specify a model name from the OpenRouter catalog, OpenRouter routes your request to the appropriate provider automatically, handling all API differences transparently.
|
||||||
|
|
||||||
### Billing
|
### Billing
|
||||||
You are billed using your OpenRouter credits. Usage (including reasoning tokens) appears in your OpenRouter dashboard.
|
You are billed using your OpenRouter credits. Usage (including reasoning tokens) appears in your OpenRouter dashboard.
|
||||||
|
|
||||||
@@ -114,6 +183,31 @@ The skill handles your API key securely and stores it in your shell environment
|
|||||||
|
|
||||||
**Privacy Note**: OpenRouter does not log your source code prompts unless you explicitly opt-in to prompt logging in your account settings. See their [Privacy Policy](https://openrouter.ai/privacy) for details.
|
**Privacy Note**: OpenRouter does not log your source code prompts unless you explicitly opt-in to prompt logging in your account settings. See their [Privacy Policy](https://openrouter.ai/privacy) for details.
|
||||||
|
|
||||||
|
## Changing Models
|
||||||
|
|
||||||
|
You can change your model at any time by:
|
||||||
|
|
||||||
|
### Option 1: Update Claude Code Settings
|
||||||
|
Edit `~/.claude/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"provider": {
|
||||||
|
"baseUrl": "https://openrouter.ai/api",
|
||||||
|
"apiKey": "${ANTHROPIC_AUTH_TOKEN}",
|
||||||
|
"defaultModel": "new-model-name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Use the Skill Again
|
||||||
|
Run the configuration process again and select a different model when prompted.
|
||||||
|
|
||||||
|
### Option 3: Per-Session Model Selection
|
||||||
|
In Claude Code, you can sometimes specify models inline:
|
||||||
|
```
|
||||||
|
/model openrouter:your-model-name
|
||||||
|
```
|
||||||
|
|
||||||
## Advanced Features
|
## Advanced Features
|
||||||
|
|
||||||
### Cost Tracking Statusline
|
### Cost Tracking Statusline
|
||||||
@@ -131,10 +225,10 @@ Download the statusline scripts from the [openrouter-examples repository](https:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### GitHub Action Integration
|
### GitHub Action Integration
|
||||||
You can use OpenRouter with the official [Claude Code GitHub Action](https://github.com/anthropics/claude-code-action). To adapt for OpenRouter, make two changes to the action step:
|
You can use OpenRouter with the official [Claude Code GitHub Action](https://github.com/anthropics/claude-code-action). To adapt the example workflow for OpenRouter, make two changes to the action step:
|
||||||
|
|
||||||
1. Pass your OpenRouter API key via `anthropic_api_key` (store it as a GitHub secret named `OPENROUTER_API_KEY`)
|
1. Pass your OpenRouter API key via `anthropic_api_key` (store it as a GitHub secret named `OPENROUTER_API_KEY`)
|
||||||
2. Set `ANTHROPIC_BASE_URL` environment variable to `https://openrouter.ai/api`
|
2. Set the `ANTHROPIC_BASE_URL` environment variable to `https://openrouter.ai/api`
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```yaml
|
```yaml
|
||||||
@@ -151,12 +245,19 @@ The [Anthropic Agent SDK](https://github.com/anthropics/anthropic-sdk-typescript
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Model Not Found Errors
|
||||||
|
- Verify the model name is copied exactly from OpenRouter's model catalog
|
||||||
|
- Check that the model is currently available on OpenRouter
|
||||||
|
- Some models may have different naming conventions (e.g., with `:free`, `:beta` suffixes)
|
||||||
|
|
||||||
### Auth Errors
|
### Auth Errors
|
||||||
- Ensure `ANTHROPIC_API_KEY` is set to an empty string (`""`)
|
- Ensure `ANTHROPIC_API_KEY` is set to an empty string (`""`)
|
||||||
- If it is unset (null), Claude Code might fall back to its default behavior and try to authenticate with Anthropic servers
|
- If it is unset (null), Claude Code might fall back to its default behavior and try to authenticate with Anthropic servers
|
||||||
|
|
||||||
### Context Length Errors
|
### Context Length Errors
|
||||||
- If you hit context limits, consider breaking your task into smaller chunks or starting a new session
|
- If you hit context limits, consider switching to a model with larger context window
|
||||||
|
- Break your task into smaller chunks or start a new session
|
||||||
|
- Check the model's context limit at https://openrouter.ai/models
|
||||||
|
|
||||||
### Previous Anthropic Login
|
### Previous Anthropic Login
|
||||||
- If you were previously logged in to Claude Code with Anthropic, run `/logout` in a Claude Code session to clear cached credentials before the OpenRouter configuration takes effect
|
- If you were previously logged in to Claude Code with Anthropic, run `/logout` in a Claude Code session to clear cached credentials before the OpenRouter configuration takes effect
|
||||||
@@ -177,11 +278,15 @@ The [Anthropic Agent SDK](https://github.com/anthropics/anthropic-sdk-typescript
|
|||||||
- "Configure OpenRouter with my API key"
|
- "Configure OpenRouter with my API key"
|
||||||
- "Set up OpenRouter as my AI provider for Claude Code"
|
- "Set up OpenRouter as my AI provider for Claude Code"
|
||||||
- "Enable OpenRouter in Claude Code"
|
- "Enable OpenRouter in Claude Code"
|
||||||
- "Configure OpenRouter with provider failover"
|
- "Configure OpenRouter with Claude 3.5 Sonnet"
|
||||||
|
- "I want to use GPT-4 through OpenRouter"
|
||||||
|
- "Help me select and configure an OpenRouter model"
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
- This skill is designed specifically for Claude Code
|
- This skill is designed specifically for Claude Code
|
||||||
- It requires write access to your shell profile (~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish)
|
- It requires write access to your shell profile (~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish)
|
||||||
- The skill ensures OpenRouter is used exclusively with Anthropic 1P as top priority
|
- The skill ensures OpenRouter is used exclusively with Anthropic 1P as top priority
|
||||||
|
- You can browse and select from 100+ models at https://openrouter.ai/models
|
||||||
|
- You can change your model at any time by editing `~/.claude/settings.json` or running this skill again
|
||||||
- You can revert to using Anthropic directly by removing these environment variables and running `/logout`
|
- You can revert to using Anthropic directly by removing these environment variables and running `/logout`
|
||||||
- Always refer to the [official OpenRouter documentation](https://openrouter.ai/docs/guides/claude-code-integration) for the most up-to-date information
|
- Always refer to the [official OpenRouter documentation](https://openrouter.ai/docs/guides/claude-code-integration) for the most up-to-date information
|
||||||
|
|||||||
@@ -1,36 +1,83 @@
|
|||||||
---
|
---
|
||||||
name: openrouter-config
|
name: openrouter-config
|
||||||
description: Use this skill when the user asks to "configure OpenRouter", "set up OpenRouter API key", "enable OpenRouter as AI provider", "configure OpenRouter in Claude Code", "set OpenRouter model", "connect Claude Code to OpenRouter", or mentions configuring OpenRouter for Claude Code.
|
description: Use this skill when the user asks to "configure OpenRouter", "set up OpenRouter API key", "enable OpenRouter as AI provider", "configure OpenRouter in Claude Code", "select an OpenRouter model", "use a specific model with OpenRouter", "connect Claude Code to OpenRouter", or mentions configuring OpenRouter for Claude Code.
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
---
|
---
|
||||||
|
|
||||||
# OpenRouter Config Skill
|
# OpenRouter Config Skill
|
||||||
|
|
||||||
Helps users configure and enable OpenRouter as the AI provider for Claude Code by setting up the OpenRouter API key, configuring Anthropic-compatible environment variables, and ensuring proper provider priority and failover capabilities.
|
Helps users configure and enable OpenRouter as the AI provider for Claude Code by letting them select their preferred model from the OpenRouter catalog, setting up the API key, configuring Anthropic-compatible environment variables, and ensuring proper provider priority and failover capabilities.
|
||||||
|
|
||||||
## Documentation Source
|
## Documentation Source
|
||||||
Official OpenRouter Claude Code Integration Guide: https://openrouter.ai/docs/guides/claude-code-integration
|
Official OpenRouter Claude Code Integration Guide: https://openrouter.ai/docs/guides/claude-code-integration
|
||||||
|
|
||||||
## What It Does
|
## What It Does
|
||||||
|
|
||||||
1. **API Key Setup**: Securely configures the OpenRouter API key
|
1. **Model Selection**: Prompts user to choose a model from OpenRouter's 100+ model catalog
|
||||||
2. **Environment Configuration**: Sets up Anthropic-compatible environment variables
|
2. **Model Catalog Guidance**: Provides link to https://openrouter.ai/models and instructions to copy model name
|
||||||
3. **Provider Priority**: Ensures Anthropic 1P is set as top priority provider
|
3. **API Key Setup**: Securely configures OpenRouter API key
|
||||||
4. **API Endpoint Configuration**: Configures `https://openrouter.ai/api` as the base URL
|
4. **Environment Configuration**: Sets up Anthropic-compatible environment variables
|
||||||
5. **Configuration Verification**: Validates that the configuration is working correctly
|
5. **Model Configuration**: Stores chosen model in Claude Code settings
|
||||||
6. **Failover Setup**: Enables automatic provider failover for high availability
|
6. **Provider Priority**: Ensures Anthropic 1P is set as top priority provider
|
||||||
|
7. **API Endpoint Configuration**: Configures `https://openrouter.ai/api` as the base URL
|
||||||
|
8. **Configuration Verification**: Validates that the configuration is working correctly
|
||||||
|
9. **Failover Setup**: Enables automatic provider failover for high availability
|
||||||
|
|
||||||
## Key Benefits
|
## Key Benefits
|
||||||
|
|
||||||
### 1. Provider Failover for High Availability
|
### 1. Provider Failover for High Availability
|
||||||
Anthropic's API occasionally experiences outages or rate limiting. OpenRouter automatically fails over between multiple Anthropic providers, keeping coding sessions uninterrupted.
|
Anthropic's API occasionally experiences outages or rate limiting. OpenRouter automatically fails over between multiple Anthropic providers, keeping coding sessions uninterrupted.
|
||||||
|
|
||||||
### 2. Organizational Budget Controls
|
### 2. Access to 100+ Models
|
||||||
|
Choose from models by Anthropic, OpenAI, Google, Meta, Mistral, xAI, and many more providers. Browse the complete catalog at https://openrouter.ai/models
|
||||||
|
|
||||||
|
### 3. Organizational Budget Controls
|
||||||
Centralized budget management with spending limits, credit allocation, and cost overrun prevention for teams.
|
Centralized budget management with spending limits, credit allocation, and cost overrun prevention for teams.
|
||||||
|
|
||||||
### 3. Usage Visibility and Analytics
|
### 4. Usage Visibility and Analytics
|
||||||
Complete visibility into Claude Code usage across teams, including usage patterns, real-time cost monitoring, and resource consumption tracking via the [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity).
|
Complete visibility into Claude Code usage across teams, including usage patterns, real-time cost monitoring, and resource consumption tracking via the [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity).
|
||||||
|
|
||||||
|
## Model Selection Process
|
||||||
|
|
||||||
|
### Step 1: Ask for Model Preference
|
||||||
|
When the skill starts, it will ask:
|
||||||
|
> "Which OpenRouter model would you like to use with Claude Code?"
|
||||||
|
|
||||||
|
### Step 2: Provide Model Catalog
|
||||||
|
The skill will provide a link to browse available models:
|
||||||
|
- **OpenRouter Models**: https://openrouter.ai/models
|
||||||
|
|
||||||
|
### Step 3: Guide User Selection
|
||||||
|
The skill will instruct the user to:
|
||||||
|
1. Visit https://openrouter.ai/models
|
||||||
|
2. Browse through the available models
|
||||||
|
3. Click on a model to see details (pricing, context length, features)
|
||||||
|
4. Copy the model name (click the model name to copy it)
|
||||||
|
5. Paste the model name back into the chat
|
||||||
|
|
||||||
|
### Step 4: Store Model Configuration
|
||||||
|
The skill will configure the chosen model in Claude Code settings at `~/.claude/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"provider": {
|
||||||
|
"baseUrl": "https://openrouter.ai/api",
|
||||||
|
"apiKey": "${ANTHROPIC_AUTH_TOKEN}",
|
||||||
|
"defaultModel": "user-selected-model-name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Popular Model Recommendations
|
||||||
|
|
||||||
|
| Model | Provider | Best For | Price Level |
|
||||||
|
|-------|----------|----------|-------------|
|
||||||
|
| `anthropic/claude-3.5-sonnet` | Anthropic | General coding, reasoning | High |
|
||||||
|
| `anthropic/claude-3.5-sonnet:beta` | Anthropic | Latest Claude features | High |
|
||||||
|
| `openai/gpt-4-turbo` | OpenAI | Fast, cost-effective | Medium-High |
|
||||||
|
| `google/gemini-pro-1.5` | Google | Long context tasks | Medium |
|
||||||
|
| `meta-llama/llama-3.1-70b-instruct:free` | Meta | Free tier usage | Free |
|
||||||
|
| `mistralai/mistral-large` | Mistral | Multilingual tasks | Medium |
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Environment Variables to Configure
|
### Environment Variables to Configure
|
||||||
@@ -71,8 +118,14 @@ https://openrouter.ai/api
|
|||||||
### Authentication
|
### Authentication
|
||||||
OpenRouter API key (get from https://openrouter.ai/keys)
|
OpenRouter API key (get from https://openrouter.ai/keys)
|
||||||
|
|
||||||
|
### Model Selection
|
||||||
|
- Browse models at: https://openrouter.ai/models
|
||||||
|
- Click on any model to see details and copy the model name
|
||||||
|
- Paste the model name when prompted by the skill
|
||||||
|
- Model is stored in `~/.claude/settings.json` as the default model
|
||||||
|
|
||||||
### Provider Priority
|
### Provider Priority
|
||||||
**Critical**: Set **Anthropic 1P** as top priority provider for maximum compatibility with Claude Code.
|
**Critical**: Set **Anthropic 1P** as the top priority provider for maximum compatibility with Claude Code.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -82,6 +135,9 @@ OpenRouter API key (get from https://openrouter.ai/keys)
|
|||||||
"Enable OpenRouter in Claude Code"
|
"Enable OpenRouter in Claude Code"
|
||||||
"Configure OpenRouter for Claude Code"
|
"Configure OpenRouter for Claude Code"
|
||||||
"Connect Claude Code to OpenRouter"
|
"Connect Claude Code to OpenRouter"
|
||||||
|
"I want to use Claude 3.5 Sonnet through OpenRouter"
|
||||||
|
"Help me select and configure an OpenRouter model"
|
||||||
|
"Set up OpenRouter with GPT-4"
|
||||||
```
|
```
|
||||||
|
|
||||||
## How It Works
|
## How It Works
|
||||||
@@ -92,6 +148,9 @@ Claude Code speaks its native protocol directly to OpenRouter when `ANTHROPIC_BA
|
|||||||
### Anthropic Skin
|
### Anthropic Skin
|
||||||
OpenRouter's "Anthropic Skin" behaves exactly like the Anthropic API, handling model mapping and passing through advanced features like "Thinking" blocks and native tool use.
|
OpenRouter's "Anthropic Skin" behaves exactly like the Anthropic API, handling model mapping and passing through advanced features like "Thinking" blocks and native tool use.
|
||||||
|
|
||||||
|
### Model Routing
|
||||||
|
When a user selects a model from the OpenRouter catalog, OpenRouter routes all requests to that specific model, handling provider differences transparently.
|
||||||
|
|
||||||
### Billing
|
### Billing
|
||||||
Billed using OpenRouter credits. Usage (including reasoning tokens) appears in the OpenRouter dashboard.
|
Billed using OpenRouter credits. Usage (including reasoning tokens) appears in the OpenRouter dashboard.
|
||||||
|
|
||||||
@@ -104,10 +163,13 @@ If previously logged in to Claude Code with Anthropic, run `/logout` in a Claude
|
|||||||
`ANTHROPIC_API_KEY` must be set to an empty string (`""`), not unset. If unset (null), Claude Code may fall back to default behavior and authenticate with Anthropic servers directly.
|
`ANTHROPIC_API_KEY` must be set to an empty string (`""`), not unset. If unset (null), Claude Code may fall back to default behavior and authenticate with Anthropic servers directly.
|
||||||
|
|
||||||
### Shell Profile Persistence
|
### Shell Profile Persistence
|
||||||
Environment variables should be added to your shell profile for persistence across sessions.
|
Environment variables should be added to the user's shell profile for persistence across sessions.
|
||||||
|
|
||||||
|
### Model Name Accuracy
|
||||||
|
Model names must be copied exactly from OpenRouter's model catalog (https://openrouter.ai/models). Include any suffixes like `:free`, `:beta`, etc.
|
||||||
|
|
||||||
### Claude Code Models
|
### Claude Code Models
|
||||||
When using Claude Code through OpenRouter, you access Anthropic models including Claude 3.5 Sonnet, Claude 3 Opus, and Claude 3 Haiku.
|
When using Claude Code through OpenRouter, users can access any of the 100+ models available, including Anthropic's Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku, as well as models from OpenAI, Google, Meta, Mistral, and more.
|
||||||
|
|
||||||
## Advanced Features
|
## Advanced Features
|
||||||
|
|
||||||
@@ -144,12 +206,20 @@ The Anthropic Agent SDK uses the same environment variables for OpenRouter integ
|
|||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
|
### Model Not Found Errors
|
||||||
|
- Verify the model name is copied exactly from OpenRouter's model catalog
|
||||||
|
- Check that the model is currently available
|
||||||
|
- Some models may have different naming conventions (e.g., with `:free`, `:beta` suffixes)
|
||||||
|
- Check https://openrouter.ai/models for current availability
|
||||||
|
|
||||||
### Auth Errors
|
### Auth Errors
|
||||||
- Ensure `ANTHROPIC_API_KEY` is set to empty string (`""`)
|
- Ensure `ANTHROPIC_API_KEY` is set to empty string (`""`)
|
||||||
- Check that environment variables are set in shell profile (not just current session)
|
- Check that environment variables are set in shell profile (not just current session)
|
||||||
- Restart terminal after updating shell profile
|
- Restart terminal after updating shell profile
|
||||||
|
|
||||||
### Context Length Errors
|
### Context Length Errors
|
||||||
|
- Switch to a model with larger context window
|
||||||
|
- Check model context limits at https://openrouter.ai/models
|
||||||
- Break tasks into smaller chunks
|
- Break tasks into smaller chunks
|
||||||
- Start a new session
|
- Start a new session
|
||||||
|
|
||||||
@@ -166,34 +236,77 @@ The Anthropic Agent SDK uses the same environment variables for OpenRouter integ
|
|||||||
## Example Workflow
|
## Example Workflow
|
||||||
|
|
||||||
1. User requests: "Configure OpenRouter for Claude Code"
|
1. User requests: "Configure OpenRouter for Claude Code"
|
||||||
2. Skill prompts for OpenRouter API key
|
2. Skill asks: "Which OpenRouter model would you like to use?"
|
||||||
3. Skill adds environment variables to shell profile
|
3. Skill provides link: https://openrouter.ai/models
|
||||||
4. Skill reminds user to restart terminal
|
4. User browses models, clicks on one, and copies the model name
|
||||||
5. User restarts terminal and runs `claude`
|
5. User pastes model name back to the skill
|
||||||
6. User runs `/status` to verify configuration
|
6. Skill prompts for OpenRouter API key
|
||||||
7. User can now use Claude Code with OpenRouter's failover and analytics
|
7. Skill adds environment variables to shell profile
|
||||||
|
8. Skill configures chosen model in `~/.claude/settings.json`
|
||||||
|
9. Skill reminds user to restart terminal
|
||||||
|
10. User restarts terminal and runs `claude`
|
||||||
|
11. User runs `/status` to verify configuration
|
||||||
|
12. User can now use Claude Code with their chosen OpenRouter model
|
||||||
|
|
||||||
|
## Changing Models
|
||||||
|
|
||||||
|
Users can change their model at any time by:
|
||||||
|
|
||||||
|
### Option 1: Update Claude Code Settings
|
||||||
|
Edit `~/.claude/settings.json`:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"provider": {
|
||||||
|
"baseUrl": "https://openrouter.ai/api",
|
||||||
|
"apiKey": "${ANTHROPIC_AUTH_TOKEN}",
|
||||||
|
"defaultModel": "new-model-name"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Run the Skill Again
|
||||||
|
Re-run the configuration process and select a different model when prompted.
|
||||||
|
|
||||||
## Configuration File Location
|
## Configuration File Location
|
||||||
|
|
||||||
Environment variables are added to shell profile:
|
Environment variables are added to shell profile:
|
||||||
- `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish`
|
- `~/.bashrc`, `~/.zshrc`, or `~/.config/fish/config.fish`
|
||||||
|
|
||||||
Claude Code settings (optional):
|
Claude Code settings (includes model configuration):
|
||||||
- `~/.claude/settings.json` (for statusline)
|
- `~/.claude/settings.json`
|
||||||
|
|
||||||
|
## Model Catalog
|
||||||
|
|
||||||
|
The complete OpenRouter model catalog is available at:
|
||||||
|
- **Browse Models**: https://openrouter.ai/models
|
||||||
|
|
||||||
|
Users can filter by:
|
||||||
|
- Provider (Anthropic, OpenAI, Google, Meta, etc.)
|
||||||
|
- Features (function calling, vision, etc.)
|
||||||
|
- Context length
|
||||||
|
- Price range
|
||||||
|
- Free tier availability
|
||||||
|
|
||||||
## Supported Models
|
## Supported Models
|
||||||
|
|
||||||
Anthropic models accessed through OpenRouter:
|
OpenRouter supports 100+ models from various providers. Users browse and select their preferred model at https://openrouter.ai/models
|
||||||
- Claude 3.5 Sonnet
|
|
||||||
- Claude 3 Opus
|
|
||||||
- Claude 3 Haiku
|
|
||||||
|
|
||||||
Model selection depends on Claude Code configuration and OpenRouter model routing settings.
|
**Popular Anthropic Models:**
|
||||||
|
- `anthropic/claude-3.5-sonnet` - Latest, most capable
|
||||||
|
- `anthropic/claude-3-opus` - Best for complex tasks
|
||||||
|
- `anthropic/claude-3-haiku` - Fast, cost-effective
|
||||||
|
|
||||||
|
**Popular Alternative Models:**
|
||||||
|
- `openai/gpt-4-turbo` - GPT-4 with Turbo speed
|
||||||
|
- `google/gemini-pro-1.5` - Long context (up to 1M tokens)
|
||||||
|
- `meta-llama/llama-3.1-70b-instruct:free` - Free Llama 3 model
|
||||||
|
- `mistralai/mistral-large` - Strong multilingual capabilities
|
||||||
|
|
||||||
## Related Resources
|
## Related Resources
|
||||||
|
|
||||||
- [OpenRouter Claude Code Integration Guide](https://openrouter.ai/docs/guides/claude-code-integration)
|
- [OpenRouter Claude Code Integration Guide](https://openrouter.ai/docs/guides/claude-code-integration)
|
||||||
|
- [OpenRouter Model Catalog](https://openrouter.ai/models)
|
||||||
- [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity)
|
- [OpenRouter Activity Dashboard](https://openrouter.ai/dashboard/activity)
|
||||||
- [OpenRouter API Keys](https://openrouter.ai/keys)
|
- [OpenRouter API Keys](https://openrouter.ai/keys)
|
||||||
- [OpenRouter Examples Repository](https://github.com/openrouter/openrouter-examples)
|
- [OpenRouter Examples Repository](https://github.com/openrouter/openrouter-examples)
|
||||||
- [Anthropic Agent SDK](https://github.com/anthropics/anthropic-sdk-typescript)
|
- [Anthropic Agent SDK](https://github.com/anthropics/anthropic-sdk-typescript)
|
||||||
|
|||||||
Reference in New Issue
Block a user