> For the complete documentation index, see [llms.txt](https://docs.interactive.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.interactive.ai/llm-router/api-guides/authentication.md).

# Authentication

API keys handle billing for model usage on the InteractiveAI Router.

### How Authentication Works

The Router authenticates requests via Bearer tokens in the Authorization header. This approach enables direct usage with `curl` or compatibility with the OpenAI SDK.

API keys on the InteractiveAI Router offer more functionality than provider-specific keys. They support configurable credit limits for applications and can be integrated into OAuth flows.

### Using an API key

First, generate a key from your account. Assign a name and optionally configure a credit limit.

When calling the Router API directly, include your key as a Bearer token in the Authorization header.

When using the OpenAI SDK, set the base URL to `https://app.interactive.ai/api/v1` and provide your key as the `apiKey` parameter.

{% tabs %}
{% tab title="Python (OpenAI SDK)" %}

```python
from openai import OpenAI

client = OpenAI(
  base_url="https://app.interactive.ai/api/v1",
  api_key="<LLMROUTER_API_KEY>",
)

response = client.chat.completions.create(
  model="openai/gpt-4o",
  messages=[
        {"role": "system", "content": "You are a data analysis assistant."},
        {"role": "user", "content": "Summarize the key metrics from this dataset."}
    ],
)

reply = response.choices[0].message
```

{% endtab %}

{% tab title="cURL" %}

```shell
curl https://app.interactive.ai/api/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $LLMROUTER_API_KEY" \
  -d '{
  "model": "openai/gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a data analysis assistant."},
      {"role": "user", "content": "Identify trends in this quarterly report."}
    ]
}'
```

{% endtab %}
{% endtabs %}

### Compromised Keys

Never expose API keys in public repositories or client-side code.

InteractiveAI participates in GitHub's secret scanning program and employs additional detection methods for exposed credentials. If a compromise is detected, you will receive an email notification.

Upon notification, or if you suspect exposure, immediately visit your key settings page to revoke the compromised key and generate a replacement.

Store keys in environment variables and exclude them from version control.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.interactive.ai/llm-router/api-guides/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
