Configure Aider to use OpenRouter API with custom models and prompt caching for cost-effective AI-assisted coding.
Configure Aider to use OpenRouter's API with flexible model selection and cost-saving features.
This skill shows you how to set up Aider with OpenRouter as your AI provider, allowing access to multiple models (Deepseek, Gemini, Mistral, etc.) through a single API key. Includes optional prompt caching to reduce costs on repeated operations.
1. Navigate to the OpenRouter settings page at https://openrouter.ai/settings/keys
2. Create a new API key if you don't have one
3. Copy the API key (starts with `sk-`)
4. Store it securely - you'll need it for configuration
1. Create or edit the Aider configuration file at `~/.aider.conf.yml`
2. Add the following configuration structure:
```yaml
api-key:
- openrouter=sk-YOUR_ACTUAL_KEY_HERE
model: openrouter/mistralai/devstral-2512:free
cache-prompts: true
```
3. Replace `sk-YOUR_ACTUAL_KEY_HERE` with your actual OpenRouter API key from Step 1
Select a model from OpenRouter's available options. Common choices include:
Update the `model:` field with your preferred model identifier.
**Prompt Caching** (Recommended):
1. Open a terminal
2. Run `aider --help` to confirm Aider recognizes your configuration
3. Start an Aider session: `aider` (or `aider <file>` to edit specific files)
4. Confirm the model loads and responds correctly
**Example 1: Using Deepseek Model**
```yaml
api-key:
- openrouter=sk-or-v1-abc123...
model: openrouter/deepseek/deepseek-chat
cache-prompts: true
```
**Example 2: Multiple Providers**
```yaml
api-key:
- openrouter=sk-or-v1-abc123...
- anthropic=sk-ant-abc123...
model: openrouter/google/gemini-2.0-flash-exp:free
cache-prompts: true
```
**Example 3: Cost-Optimized Setup**
```yaml
api-key:
- openrouter=sk-or-v1-abc123...
model: openrouter/mistralai/devstral-2512:free
cache-prompts: true
cache-keepalive-pings: 5
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/aider-configuration-for-openrouter-api/raw