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

# Cursor + OpenRouter Setup

> Use Claude-Mem in Cursor with OpenRouter's 100+ AI models

# Cursor + OpenRouter Setup

This guide walks you through setting up Claude-Mem in Cursor using OpenRouter. OpenRouter provides access to 100+ AI models from various providers, including several free options.

<Info>
  **Model variety:** Access Claude, GPT-4, Gemini, Llama, Mistral, and many more through a single API key.
</Info>

## Step 1: Get an OpenRouter API Key

1. Go to [OpenRouter](https://openrouter.ai)
2. Sign up or sign in
3. Navigate to [API Keys](https://openrouter.ai/keys)
4. Click **Create Key**
5. Copy your API key - you'll need it in Step 3

<Tip>
  **Free models available:** OpenRouter offers free versions of several models including Gemini Flash and others. Check the [model list](https://openrouter.ai/models?show_free=true) for current free options.
</Tip>

## Step 2: Clone and Build Claude-Mem

```bash theme={null}
# Clone the repository
git clone https://github.com/thedotmack/claude-mem.git
cd claude-mem

# Install dependencies
bun install

# Build the project
bun run build
```

## Step 3: Configure OpenRouter Provider

### Option A: Interactive Setup (Recommended)

Run the setup wizard which guides you through everything:

```bash theme={null}
bun run cursor:setup
```

When prompted for provider, select **OpenRouter**.

### Option B: Manual Configuration

Create the settings file manually:

```bash theme={null}
# Create settings directory
mkdir -p ~/.claude-mem

# Create settings file with OpenRouter configuration
cat > ~/.claude-mem/settings.json << 'EOF'
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_OPENROUTER_API_KEY"
}
EOF
```

Replace `YOUR_OPENROUTER_API_KEY` with your actual API key.

Then install hooks and start the worker:

```bash theme={null}
bun run cursor:install
bun run worker:start
```

## Step 4: Restart Cursor

Close and reopen Cursor IDE for the hooks to take effect.

## Step 5: Verify Installation

```bash theme={null}
# Check worker is running
bun run worker:status

# Check hooks are installed
bun run cursor:status
```

Open [http://localhost:37777](http://localhost:37777) to see the memory viewer.

## Recommended Models

### Free Models

| Model                              | Provider | Notes                |
| ---------------------------------- | -------- | -------------------- |
| `google/gemini-2.0-flash-exp:free` | Google   | Fast, capable        |
| `xiaomi/mimo-v2-flash:free`        | Xiaomi   | Good general purpose |

### Paid Models (Low Cost)

| Model                           | Approx. Cost        | Notes           |
| ------------------------------- | ------------------- | --------------- |
| `anthropic/claude-3-haiku`      | \~\$0.25/1M tokens  | Fast, efficient |
| `google/gemini-flash-1.5`       | \~\$0.075/1M tokens | Great value     |
| `mistralai/mistral-7b-instruct` | \~\$0.07/1M tokens  | Budget option   |

To specify a model, add to your settings:

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "your-key",
  "CLAUDE_MEM_OPENROUTER_MODEL": "google/gemini-2.0-flash-exp:free"
}
```

## Custom OpenAI-Compatible Endpoints

The OpenRouter provider is a generic OpenAI-compatible client. Set `CLAUDE_MEM_OPENROUTER_BASE_URL` to point it at any endpoint that speaks the OpenAI `/chat/completions` API — DeepSeek, a local LM Studio server, or any custom gateway. The model id you set in `CLAUDE_MEM_OPENROUTER_MODEL` is sent verbatim.

<Info>
  **Base URL resolution:** When `CLAUDE_MEM_OPENROUTER_BASE_URL` is empty (default), requests go to OpenRouter unchanged. When set, claude-mem POSTs to `<base_url>/chat/completions` — you can supply either a base like `https://api.deepseek.com/v1` (the `/chat/completions` path is appended automatically) or a full `.../chat/completions` URL (used verbatim). Trailing slashes are normalized. The environment variable `OPENROUTER_BASE_URL` is honored as a fallback.
</Info>

### DeepSeek

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_BASE_URL": "https://api.deepseek.com",
  "CLAUDE_MEM_OPENROUTER_MODEL": "deepseek-chat",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_DEEPSEEK_API_KEY"
}
```

### LM Studio (local model)

LM Studio exposes an OpenAI-compatible server. No API key is required for local use, and you can use any model id you have loaded.

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_BASE_URL": "http://localhost:1234/v1",
  "CLAUDE_MEM_OPENROUTER_MODEL": "your-local-model-id"
}
```

### Generic custom endpoint

Any OpenAI-compatible gateway works the same way:

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_BASE_URL": "https://my-gateway.example.com/v1",
  "CLAUDE_MEM_OPENROUTER_MODEL": "model-id",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "YOUR_KEY"
}
```

## Cost Management

OpenRouter charges per token. To manage costs:

1. **Use free models:** Several high-quality free models are available
2. **Monitor usage:** Check your [OpenRouter dashboard](https://openrouter.ai/activity)
3. **Set spending limits:** Configure limits in OpenRouter settings

<Warning>
  **Cost awareness:** Unlike Gemini's free tier, OpenRouter paid models charge per request. Monitor your usage if using paid models.
</Warning>

## Troubleshooting

### "OpenRouter API key not configured"

Ensure your settings file exists with the correct format:

```bash theme={null}
cat ~/.claude-mem/settings.json
```

Should output something like:

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "openrouter",
  "CLAUDE_MEM_OPENROUTER_API_KEY": "sk-or-..."
}
```

### Model not found

1. Check the model ID is correct at [OpenRouter Models](https://openrouter.ai/models)
2. Some models may require payment - check if you have credits
3. Free models have `:free` suffix in their ID

### Rate limits

OpenRouter rate limits vary by model and your account tier. If you hit limits:

1. Wait briefly and retry
2. Consider upgrading your OpenRouter account tier
3. Switch to a less popular model

### API errors

Check the worker logs for details:

```bash theme={null}
bun run worker:logs
```

Common issues:

* Invalid API key (regenerate at OpenRouter)
* Insufficient credits for paid models
* Model temporarily unavailable

## Switching Providers Later

You can switch between OpenRouter, Gemini, and Claude SDK at any time by updating your settings. No restart required - changes take effect on the next observation.

```json theme={null}
{
  "CLAUDE_MEM_PROVIDER": "gemini"
}
```

## Next Steps

* [Cursor Integration Overview](/cursor/index) - All Cursor features
* [Gemini Setup](/cursor/gemini-setup) - Alternative free provider
* [Configuration Reference](../configuration) - All settings options
