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

# Authentication

> Each model has its own API key. Send it as a bearer token on every request.

Source: https://docs.heurastudios.com/api/authentication/

Every request sends the model's key in the `Authorization` header:

```http
Authorization: Bearer hs_0123456789abcdef0123456789abcdef
```

## The key

- **Format:** `hs_` followed by 32 hexadecimal characters.
- **One per model.** A key calls only the model it belongs to.
- **Where:** the model's **api** tab, for the model's owner. Teammates don't see it.
- **Stored as a hash.** Heura Studios never keeps the key itself, so copy it when it's shown.

## Rotating a key

**New key** on the api tab replaces the key at once: apps and scripts using the old one stop working on their next request. The website agent isn't affected, since it doesn't use the key.

## A missing or wrong key

```json
{
  "error": {
    "message": "Incorrect API key. Find this AI's key under Deploy in Heura Studios.",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}
```

The response is `401`. A valid key on an account whose plan doesn't include the API gets `403` with `plan_required`.

## Keeping keys safe

- Call the API from your server. Never put a key in browser or mobile code; for a website, use the [website agent](https://docs.heurastudios.com/ship/website-agent/), which needs no key.
- Keep keys in environment variables or a secret manager.
- Rotate a key the moment you suspect it leaked.

> **Note:**
>
> Agent keys (`hs_agent_...`) are a different kind of key, for [Agent mode](https://docs.heurastudios.com/agents/keys/). They don't work on `/v1`, and model keys don't work for Agent mode.
