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

# Authentication

> Create an API key and send it as a bearer token.

All requests authenticate with an API key sent as a bearer token in the `Authorization` header.

## Get an API key

<Steps>
  <Step title="Create an account">
    Sign up at [redpill.ai](https://www.redpill.ai/register).
  </Step>

  <Step title="Generate a key">
    In the [dashboard](https://www.redpill.ai/dashboard), create an API key.
  </Step>

  <Step title="Add credits">
    Add credits to start making requests.
  </Step>
</Steps>

## Use the key

Store the key in an environment variable, then send it as a bearer token:

<CodeGroup>
  ```bash cURL theme={null}
  export API_KEY="your-api-key"

  curl https://api.redpill.ai/v1/chat/completions \
    -H "Authorization: Bearer $API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "qwen/qwen3-30b-a3b-instruct-2507", "messages": [{"role": "user", "content": "Hello"}]}'
  ```

  ```python Python theme={null}
  import os
  from openai import OpenAI

  client = OpenAI(base_url="https://api.redpill.ai/v1", api_key=os.environ["API_KEY"])
  ```

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

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

## Keep keys safe

* Read the key from an environment variable or a secret manager. Never hardcode it in source.
* Add `.env` files to `.gitignore`.
* Use separate keys for development and production, and revoke a key in the
  [dashboard](https://www.redpill.ai/dashboard) if it is exposed.
* Call the API from your backend, not from browser or mobile client code.

## Errors

A missing or invalid key returns an authentication error:

```json theme={null}
{
  "error": {
    "message": "Invalid API key provided",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}
```

See [Error handling](/guides/error-handling) for the full list.

## FAQ

<AccordionGroup>
  <Accordion title="Can I use my OpenAI API key?">
    No, you need a key from this platform. The API works with OpenAI client libraries, so you keep the
    same SDKs and code: just change the API key and base URL.
  </Accordion>

  <Accordion title="Where do I see usage and rate limits?">
    Check your balance, usage, and current rate limits in the
    [dashboard](https://www.redpill.ai/dashboard).
  </Accordion>
</AccordionGroup>
