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

# OpenRouter

> Use OpenRouter models through the ngrok AI Gateway.

[OpenRouter](https://openrouter.ai) is a unified API that provides access to hundreds of models from providers like Anthropic, Google, Meta, Mistral, and more through a single endpoint.

<Note>
  Even though OpenRouter is a **built-in provider**, it still requires you to **bring your own key** because ngrok.ai inference is not available for it at this time.
</Note>

## Setup

<Steps>
  <Step title="Create an access key">
    Follow the [quickstart](/ai-gateway/quickstart) to create an access key in [app.ngrok.ai](https://app.ngrok.ai).
  </Step>

  <Step title="Store your OpenRouter API key">
    Create an account at [openrouter.ai](https://openrouter.ai) and generate an API key from your dashboard. Then [add a provider key](/ai-gateway/guides/attaching-provider-keys#add-a-provider-key).
  </Step>

  <Step title="Create a configuration">
    [Create an access key configuration](/ai-gateway/guides/access-key-configurations#create-a-configuration) with an `openrouter` routing rule and allow OpenRouter in the access scope.
  </Step>

  <Step title="Assign and send requests">
    Assign the configuration to your access key and send requests with your access key:

    ```python theme={null}
    from openai import OpenAI

    client = OpenAI(
        base_url="https://gateway.ngrok.ai/v1",
        api_key="ng-xxxxx-g1-xxxxx",
    )

    response = client.chat.completions.create(
        model="openrouter:anthropic/claude-3.5-sonnet",
        messages=[{"role": "user", "content": "Hello!"}]
    )
    ```
  </Step>
</Steps>

## Model names

<Warning>
  Always prefix OpenRouter model IDs with `openrouter:`. Without the prefix, the gateway may route to the native provider instead of OpenRouter.
</Warning>

OpenRouter uses a `provider/model` format for its model IDs. When calling through the ngrok AI Gateway, prefix with `openrouter:`:

| What you want                   | Model string to use                           |
| ------------------------------- | --------------------------------------------- |
| Anthropic Claude via OpenRouter | `openrouter:anthropic/claude-3.5-sonnet`      |
| Google Gemini via OpenRouter    | `openrouter:google/gemini-2.0-flash-001`      |
| Meta Llama via OpenRouter       | `openrouter:meta-llama/llama-3.1-8b-instruct` |
| Mistral via OpenRouter          | `openrouter:mistralai/mistral-7b-instruct`    |

The `openrouter:` prefix tells the gateway to route to OpenRouter specifically, not to the native provider. Without it, `anthropic/claude-3.5-sonnet` would fail—the gateway doesn't recognize the slash-separated format as a valid model without the provider prefix.

For the full list of models OpenRouter supports, see [openrouter.ai/models](https://openrouter.ai/models).

## Available models

See the [model catalog](/ai-gateway/reference/model-catalog#openrouter).

## Next steps

* [Provider Keys](/ai-gateway/guides/attaching-provider-keys)
* [Access Key Configurations](/ai-gateway/guides/access-key-configurations)
* [Multi-provider failover](/ai-gateway/examples/multi-provider-failover): failover patterns
* [Choose a model](/ai-gateway/guides/model-selection-strategies): model IDs and provider prefixes
