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

# OpenRouter

> Add AI models from OpenRouter to use in AI Studio agents

This guide shows you how to configure OpenRouter as an external model provider in AI Studio. After setting up this provider, you can use models from OpenRouter's unified catalog when building agents.

## Prerequisites

Before adding OpenRouter models to AI Studio, you need:

* An [OpenRouter account](https://openrouter.ai/)
* An OpenRouter API key (starts with `sk-or-...`, see [Get an OpenRouter API key](#get-an-openrouter-api-key))

<Warning>
  AI Studio supports **text generation** and **embedding** models from
  OpenRouter. Video, audio, and image generation models are not supported.
</Warning>

## Get an OpenRouter API key

OpenRouter authenticates requests with a single API key that works across its model catalog. Create one from your OpenRouter account.

1. Sign up or log in at [OpenRouter](https://openrouter.ai/)
2. Navigate to the [API Keys](https://openrouter.ai/keys) page
3. Select **Create Key**
4. Enter a name for the key (for example, `AI Studio integration`)
5. Copy the key, which starts with `sk-or-...`

For more details, see the [OpenRouter quickstart](https://openrouter.ai/docs/quickstart).

<Warning>
  Store your API key securely. If a key is compromised, revoke it from the
  [API Keys](https://openrouter.ai/keys) page and create a new one.
</Warning>

## Add OpenRouter models in AI Studio

After creating your API key, add OpenRouter models to AI Studio.

1. Navigate to **Models & Guardrails > Models** in [AI Studio](https://app.writer.com/aistudio)
2. Select **+ Add model**
3. Select **OpenRouter** as the provider
4. Select the model you want to add from the **Model name** dropdown
5. Enter a **Display name** for the model
6. Provide your credentials using one of the following options:
   * Select an existing credential set from the **Credentials name** dropdown
   * Enter a new **Credential name** and your **OpenRouter API key** to save credentials for reuse
7. Configure team access:
   * **All teams**: Anyone with builder access can use the model
   * **Specific teams**: Restrict to selected teams
8. Select **Save**

<img src="https://mintcdn.com/writer/iljD9sjySSSg4wwQ/images/home/openrouter-config-form.png?fit=max&auto=format&n=iljD9sjySSSg4wwQ&q=85&s=f4031eb6a29e54e57eaefd1db79c2a13" alt="" width="2910" height="1734" data-path="images/home/openrouter-config-form.png" />

## Monitor costs

OpenRouter bills usage directly to your OpenRouter account based on the tokens processed by each model. WRITER also charges a [10% pass-through fee](/home/pricing#external-models-byom) on external model usage, paid via credits. AI Studio tracks usage and costs for external models, providing visibility into spending across all your models in one place.

## Troubleshoot OpenRouter configuration

### Invalid API key error

If you see an "Invalid API key" or "Authentication failed" error:

* Verify the API key is copied correctly without extra spaces
* Confirm the key starts with `sk-or-...`
* Check that the key is still active on the [API Keys](https://openrouter.ai/keys) page
* Ensure your OpenRouter account has sufficient credits

### Model not available error

If a model doesn't appear or returns an error:

* Confirm the model is available in the [OpenRouter model catalog](https://openrouter.ai/models)
* Verify your OpenRouter account has access to the model
* Check that your account has credits to run the model

## Next steps

* [Add external models](/home/external-models): Learn about managing external models in AI Studio
* [Choose a model](/home/models-overview): Compare Palmyra models with external provider models
* [OpenRouter quickstart](https://openrouter.ai/docs/quickstart): Explore OpenRouter's full capabilities
