Providers

How to Use OpenRouter with Claude Code Through Prism

By Kavin M KPublished Updated 7 min read

Quick answer
Add OpenRouter as a custom provider with base URL https://openrouter.ai/api/v1 and your OpenRouter key, add the models you want, then alias the names Claude Code sends to them. Prism translates Anthropic Messages to Chat Completions and back.

OpenRouter is a unified API gateway that provides access to hundreds of models from dozens of providers through a single endpoint. Instead of managing separate API keys for Anthropic, OpenAI, DeepSeek, Groq, Mistral, and more, you get one key and one base URL that routes to any model you want.

Combining OpenRouter with Prism and Claude Code gives you the best of all worlds: Claude Code's agent capabilities, OpenRouter's model breadth, and Prism's transparent format translation. You can switch between GPT-4o, DeepSeek, Llama, Gemini, and hundreds of others just by changing a model name in your remapping config.

Why OpenRouter

The main appeal is breadth. Over 300 models are available through one API, including models from providers that do not offer direct API access. OpenRouter also handles failover automatically — if one provider is down, it can route to a backup. Pricing is transparent and pay-as-you-go, often matching the underlying provider's rates.

Step by step

1

Get an OpenRouter API key

Sign in at openrouter.ai and create an API key from the dashboard.
2

Add OpenRouter as a custom provider in Prism

Open the Prism admin UI at http://127.0.0.1:8765/admin, go to the Provider tab, and click Add custom provider. Set the base URL to https://openrouter.ai/api/v1 and paste your API key.
3

Add models

In the Models tab, auto-fill from models.devto pull in OpenRouter's catalog, or add specific models manually. OpenRouter model names use a provider-prefixed format like deepseek/deepseek-chat or google/gemini-2.5-pro.
4

Set up Claude Code

Go to the Agents tab and click Setup next to Claude Code for one-click integration.

Manual environment variables

$env:ANTHROPIC_BASE_URL = "http://127.0.0.1:11434"
    $env:ANTHROPIC_AUTH_TOKEN = "prism"

Model remapping

Map Claude Code's Anthropic model names to OpenRouter models:

// %APPDATA%\prism\model_remapping.json
    {
      "default_model": "deepseek/deepseek-chat",
      "known_models": [
        { "id": "deepseek/deepseek-chat",            "provider": "custom_openrouter" },
        { "id": "meta-llama/llama-3.3-70b-instruct", "provider": "custom_openrouter" },
        { "id": "google/gemini-2.5-pro",             "provider": "custom_openrouter" }
      ],
      "aliases": {
        "claude-3-5-sonnet-20241022": "deepseek/deepseek-chat",
        "claude-3-5-haiku-20241022":  "meta-llama/llama-3.3-70b-instruct",
        "claude-3-opus-20240229":     "google/gemini-2.5-pro"
      }
    }

Using multiple models

One of the biggest advantages of OpenRouter is that you can mix models from different providers in a single configuration. You are not locked to one provider's model family. Your per-tier remapping can draw from completely different providers:

// Per-tier selection lives in Claude Code, not in the remapping file
    ANTHROPIC_DEFAULT_OPUS_MODEL   = "google/gemini-2.5-pro"
    ANTHROPIC_DEFAULT_SONNET_MODEL = "deepseek/deepseek-chat"
    ANTHROPIC_DEFAULT_HAIKU_MODEL  = "meta-llama/llama-3.3-70b-instruct"
    CLAUDE_CODE_SUBAGENT_MODEL     = "qwen/qwen-2.5-coder-32b-instruct"

This per-tier approach lets you use premium models only where they matter most, while keeping costs down with cheaper models for background and sub-agent work. Because OpenRouter handles the routing to each underlying provider, you only need one API key.

Config example

// %APPDATA%\prism\config.json
    {
      "custom_providers": [
        {
          "id": "custom_openrouter_7g8h9i",
          "name": "OpenRouter",
          "base_url": "https://openrouter.ai/api/v1",
          "api_key": "sk-or-v1-your-key"
        }
      ]
    }
Tip
OpenRouter accepts optional ranking headers such as HTTP-Referer and X-Title, but Prism does not send extra headers upstream on a provider's behalf — a provider entry is just a base URL and a key. To label your own traffic in the Stats dashboard, have the client send X-Client-Name.

Get started

Download Prism, add OpenRouter as a custom provider, remap your models, and start Claude Code. You will have access to hundreds of models through a single API key in minutes.

Download Prism

Reference

Every claim on this page is checked against the Prism source, and the reference documentation is where those details live in full.

Try it yourself

Prism is a free, MIT-licensed local proxy for AI coding agents. Install it, point one agent at http://127.0.0.1:11434, and the rest of this post applies as written.