> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/ai/llm/providers/openrouter.md).

# OpenRouter

Connect OpenRouter as an LLM integration.

OpenRouter gives you models of many vendors behind one key and one bill.

## Get your credentials

1. Open [OpenRouter](https://openrouter.ai/) and sign in.
2. Buy credits under **Credits** (some models are free, with low limits).
3. Open [Keys](https://openrouter.ai/settings/keys), press **Create Key**, name it, optionally set a credit limit, and copy the key (it starts with `sk-or-`).
4. Pick a model id from the [models list](https://openrouter.ai/models), written as `vendor/model`, for example `openai/gpt-4o-mini`.

More in the provider's own guide: [OpenRouter quickstart](https://openrouter.ai/docs/quickstart).

## Connect it in Cloud

**Where:** Project → Integrations → LLM → **Add New Integration** → OpenRouter → **Connect** · `/projects/<project>/ai/llms/integrations/new/openrouter`

| Field            | Required | What it does                                                              | Example                      |
| ---------------- | -------- | ------------------------------------------------------------------------- | ---------------------------- |
| API Key          | yes      | The OpenRouter key. Stored encrypted, never shown again.                  | `sk-or-placeholder-not-real` |
| Endpoint         | no       | Another address. Empty = `https://openrouter.ai/api/v1`.                  | empty                        |
| Default Model    | no       | The model used when a request names none. Empty = the provider's default. | `openai/gpt-4o-mini`         |
| Integration Name | yes      | How the integration is listed in Norbix.                                  | `Many models`                |

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-46d5ef7a37447ef8e326b40d03f7d1a0832d77fb%2Fopenrouter-form-1.png?alt=media" alt="New OpenRouter Integration form filled with placeholder values"><figcaption><p>The filled form (the key is a made-up placeholder).</p></figcaption></figure>

Press **Save**. The title becomes *Editing OpenRouter integration*, the badges say **ENABLED** and **NOT TESTED**, the id (`int_…`) appears with a copy button, the key field is empty again with the note that the key will not be displayed, and the test panel appears at the bottom.

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-807e3ea031141beed8a88f456a58627a9b9cd1ca%2Fopenrouter-saved-2.png?alt=media" alt="The OpenRouter integration after save: badges ENABLED and NOT TESTED, the integration id, and the Test integration panel"><figcaption><p>After save.</p></figcaption></figure>

## Test and set as default

**Test integration** checks only that Norbix can read the stored key; it does not call OpenRouter, so a wrong key also passes — see [Test an LLM integration](/codemash/cloud/ai/llm/test.md). Ask the [AI chat](/codemash/cloud/ai/ai-chat.md) a question to check it for real.

The first LLM of an environment gets the **DEFAULT** badge. To make this one the model the AI uses, pick it as the project's **Default LLM** — see [Set the default LLM](/codemash/cloud/ai/llm/set-default.md). To turn it off: [Disable or delete](/codemash/cloud/ai/llm/disable.md).

## Common errors

| Message                                                 | Cause                                                                                                                                                                                                               | Fix                                                                     |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| *Required* under **API Key**                            | The key is empty — it is asked again on every save.                                                                                                                                                                 | Type the key again.                                                     |
| *Domain URL format is invalid* (`CM-ERRORS-DOMAIN-002`) | **Endpoint** is not a full address.                                                                                                                                                                                 | Write it with `http://` or `https://`.                                  |
| *Error while running chat turn* when you ask the chat   | The provider refused the call: the key is wrong or deleted; or the account or the key limit has no credits left — Cloud does not show the reason; the server log has it (for example *Status: 401 (Unauthorized)*). | Create a new key and save it again. Buy credits or raise the key limit. |
