> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ccs.kaitran.ca/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenRouter Integration

> Access 300+ AI models through OpenRouter's unified API

# OpenRouter Integration

CCS v7.0.0 introduces OpenRouter as a first-class provider. Access 300+ AI models through a unified API with intelligent model selection and tier mapping.

## Overview

<Tabs>
  <Tab title="Dark Theme">
    <Frame>
      <img src="https://mintcdn.com/ccs-7e541244/FDk98adsJnGPdEsY/assets/api-profiles-openrouter.webp?fit=max&auto=format&n=FDk98adsJnGPdEsY&q=85&s=e3ac58f9cc8d504ca96f9f98956b873b" alt="OpenRouter API Profiles - Dark" width="4336" height="2806" data-path="assets/api-profiles-openrouter.webp" />
    </Frame>
  </Tab>

  <Tab title="Light Theme">
    <Frame>
      <img src="https://mintcdn.com/ccs-7e541244/FDk98adsJnGPdEsY/assets/light-api-profiles-openrouter.webp?fit=max&auto=format&n=FDk98adsJnGPdEsY&q=85&s=eebb7b3df755f08724931234dceab320" alt="OpenRouter API Profiles - Light" width="4336" height="2806" data-path="assets/light-api-profiles-openrouter.webp" />
    </Frame>
  </Tab>
</Tabs>

## Key Features

<CardGroup cols={2}>
  <Card title="300+ Models" icon="layer-group">
    Access Claude, GPT, Gemini, Llama, and more through one API
  </Card>

  <Card title="Interactive Picker" icon="wand-magic-sparkles">
    Visual model selection with search and filtering in CLI and UI
  </Card>

  <Card title="Tier Mapping" icon="sitemap">
    Automatic opus/sonnet/haiku tier assignment for model routing
  </Card>

  <Card title="Dynamic Discovery" icon="radar">
    Real-time detection of newest models from OpenRouter catalog
  </Card>
</CardGroup>

## Quick Start

### Via CLI

```bash theme={null}
ccs api create --preset openrouter
```

The CLI launches an interactive model picker:

1. Enter your OpenRouter API key
2. Browse or search available models
3. Select models for each tier (opus, sonnet, haiku)
4. Profile is created and ready to use

### Via Dashboard

<Steps>
  <Step title="Open Dashboard">
    ```bash theme={null}
    ccs config
    ```
  </Step>

  <Step title="Navigate to API Profiles">
    Click "API Profiles" in the sidebar (note the OpenRouter badge).
  </Step>

  <Step title="Create Profile">
    Click "Create Profile" and select "OpenRouter" from Provider Presets.
  </Step>

  <Step title="Configure Models">
    Use the model picker to select models for each tier.
  </Step>
</Steps>

## Model Tier Mapping

CCS maps OpenRouter models to Claude Code's tier system for intelligent model routing:

| Tier       | Purpose                         | Recommended Models            |
| ---------- | ------------------------------- | ----------------------------- |
| **Opus**   | Complex reasoning, architecture | Claude 3.5 Opus, GPT-4o       |
| **Sonnet** | General coding, balanced        | Claude 3.5 Sonnet, Gemini Pro |
| **Haiku**  | Quick tasks, cost-efficient     | Claude 3 Haiku, GPT-4o-mini   |

### Exacto Models

CCS prioritizes **Exacto-tuned models** for agentic performance. These models are optimized for:

* Tool calling accuracy
* Code generation quality
* Instruction following

Look for models tagged with "Exacto" in the picker for best results with Claude Code workflows.

## Configuration

### Profile Structure

OpenRouter profiles use the standard CCS settings format:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://openrouter.ai/api",
    "ANTHROPIC_AUTH_TOKEN": "sk-or-v1-xxxxx",
    "ANTHROPIC_MODEL": "anthropic/claude-3.5-sonnet",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-3-opus",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-3-haiku"
  }
}
```

### Environment Variables

| Variable                        | Description                         |
| ------------------------------- | ----------------------------------- |
| `ANTHROPIC_BASE_URL`            | Must be `https://openrouter.ai/api` |
| `ANTHROPIC_AUTH_TOKEN`          | Your OpenRouter API key             |
| `ANTHROPIC_MODEL`               | Default model (sonnet tier)         |
| `ANTHROPIC_DEFAULT_OPUS_MODEL`  | Model for opus tier                 |
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | Model for haiku tier                |

## Usage

```bash theme={null}
# Use OpenRouter profile
ccs openrouter "implement the authentication service"

# Parallel workflows
ccs openrouter "design the system"    # Terminal 1: Architecture
ccs glm "implement the service"       # Terminal 2: Bulk coding
```

## Model Selection Tips

<AccordionGroup>
  <Accordion title="Best for Agentic Workflows">
    * **anthropic/claude-3.5-sonnet** - Excellent tool use
    * **openai/gpt-4o** - Strong reasoning
    * Models with "Exacto" tag - Optimized for agents
  </Accordion>

  <Accordion title="Best for Cost Efficiency">
    * **anthropic/claude-3-haiku** - Fast and cheap
    * **openai/gpt-4o-mini** - Good balance
    * **meta-llama/llama-3.1-8b-instruct** - Open source
  </Accordion>

  <Accordion title="Best for Long Context">
    * **anthropic/claude-3.5-sonnet** - 200K context
    * **google/gemini-pro-1.5** - 1M context
    * **anthropic/claude-3-opus** - 200K context
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="API Key Issues">
    Verify your key at [openrouter.ai/keys](https://openrouter.ai/keys):

    ```bash theme={null}
    curl -H "Authorization: Bearer sk-or-v1-xxxxx" \
         https://openrouter.ai/api/v1/models
    ```
  </Accordion>

  <Accordion title="Model Not Available">
    Some models require credits or have access restrictions. Check model availability on the OpenRouter dashboard.
  </Accordion>

  <Accordion title="Rate Limits">
    OpenRouter has per-model rate limits. Switch models or upgrade your plan if hitting limits.
  </Accordion>
</AccordionGroup>

<Tip>
  Get your API key at [openrouter.ai/keys](https://openrouter.ai/keys). New accounts receive free credits to get started.
</Tip>
