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

# Authentication

> How PrimaLabs API keys work and how to create one.

Every request is authenticated with an **API key** sent as a bearer token:

```
Authorization: Bearer YOUR_API_KEY
```

There is no separate secret or signing step — the key is the credential.

## Getting a key

1. Sign in to the [dashboard](https://dashboard.primalabs.ai).
2. Create a key.
3. Copy it once and store it somewhere safe.

A key spends against your account balance and can call the models your account is
entitled to. `GET /models` returns exactly that set for the key you call it with.

## Using the key

Pass it on the `Authorization` header of every call. With an OpenAI SDK, set it as the
`api_key` / `apiKey`:

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  client = OpenAI(
      base_url="https://api.primalabs.ai/v1",
      api_key="YOUR_API_KEY",
  )
  ```

  ```javascript Node theme={null}
  import OpenAI from "openai";

  const client = new OpenAI({
    baseURL: "https://api.primalabs.ai/v1",
    apiKey: "YOUR_API_KEY",
  });
  ```
</CodeGroup>

## Keeping keys safe

<Warning>
  Never embed a key in client-side code, a mobile app, or a public repository. Anyone with
  the key can spend against your account. Call the API from your backend and keep the key in
  a server-side secret or environment variable.
</Warning>

* **Rotate** a key immediately if it may have leaked — create a new one in the dashboard
  and delete the old one.
* **Environment variables** (e.g. `PRIMALABS_API_KEY`) keep keys out of source control.
* A missing or invalid key returns [`401`](/inference/errors); a key that cannot access the
  requested model returns [`403`](/inference/errors).
