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

# Authentication

> Authenticate using a Maitai API key (and optionally provider keys).

<Note>
  You can create Maitai API keys in the Portal under `Settings` > `API Keys`. For the REST API, pass the key in the `X-Maitai-Api-Key` header.
</Note>

<img src="https://mintcdn.com/maitai-cbe2cd27/kcIewhDoyU5XOGPZ/images/portal_developers_apikeys.png?fit=max&auto=format&n=kcIewhDoyU5XOGPZ&q=85&s=19fad8972f94d6f6a6de1cd7bb7304bb" alt="api_keys" width="1006" height="320" data-path="images/portal_developers_apikeys.png" />

## Maitai API key (required)

Set `MAITAI_API_KEY`:

```bash theme={null}
export MAITAI_API_KEY="<YOUR_MAITAI_API_KEY>"
```

Or pass it directly when constructing the client:

<CodeGroup>
  ```python Python theme={null}
  import maitai

  client = maitai.Maitai(
      maitai_api_key="<YOUR_MAITAI_API_KEY>",
  )
  ```

  ```javascript Node theme={null}
  import Maitai from "maitai";

  const maitai = new Maitai({
    maitaiApiKey: "<YOUR_MAITAI_API_KEY>",
  });
  ```
</CodeGroup>

## Provider keys (optional)

Maitai can run requests across multiple providers. You can supply provider keys in two ways.

### Option A: Environment variables

```bash theme={null}
export OPENAI_API_KEY="<YOUR_OPENAI_API_KEY>"
export GROQ_API_KEY="<YOUR_GROQ_API_KEY>"
export ANTHROPIC_API_KEY="<YOUR_ANTHROPIC_API_KEY>"
export CEREBRAS_API_KEY="<YOUR_CEREBRAS_API_KEY>"
export SAMBANOVA_API_KEY="<YOUR_SAMBANOVA_API_KEY>"
export GEMINI_API_KEY="<YOUR_GEMINI_API_KEY>"
```

<Note>
  The Python SDK also supports DeepSeek (`DEEPSEEK_API_KEY` / `deepseek_api_key`).
</Note>

### Option B: Pass provider keys into the SDK constructor

<CodeGroup>
  ```python Python theme={null}
  import maitai

  client = maitai.Maitai(
      maitai_api_key="<YOUR_MAITAI_API_KEY>",
      openai_api_key="<YOUR_OPENAI_API_KEY>",
      groq_api_key="<YOUR_GROQ_API_KEY>",
      anthropic_api_key="<YOUR_ANTHROPIC_API_KEY>",
      cerebras_api_key="<YOUR_CEREBRAS_API_KEY>",
      sambanova_api_key="<YOUR_SAMBANOVA_API_KEY>",
      gemini_api_key="<YOUR_GEMINI_API_KEY>",
      deepseek_api_key="<YOUR_DEEPSEEK_API_KEY>",
  )
  ```

  ```javascript Node theme={null}
  import Maitai from "maitai";

  const maitai = new Maitai({
    maitaiApiKey: "<YOUR_MAITAI_API_KEY>",
    openaiApiKey: "<YOUR_OPENAI_API_KEY>",
    groqApiKey: "<YOUR_GROQ_API_KEY>",
    anthropicApiKey: "<YOUR_ANTHROPIC_API_KEY>",
    cerebrasApiKey: "<YOUR_CEREBRAS_API_KEY>",
    sambanovaApiKey: "<YOUR_SAMBANOVA_API_KEY>",
    geminiApiKey: "<YOUR_GEMINI_API_KEY>",
  });
  ```
</CodeGroup>

<Note>
  If your company has provider keys configured in the Portal, the SDK can automatically use them after it initializes (so you don’t have to set provider env vars in every environment).
</Note>

## Managing provider keys in the Portal

To better organize credentials across environments, you can store provider keys in the Portal and associate them with a Maitai key. This lets you keep `MAITAI_API_KEY` as the only required secret for most integrations.

<img src="https://mintcdn.com/maitai-cbe2cd27/kcIewhDoyU5XOGPZ/images/auth/settings_apikeys.png?fit=max&auto=format&n=kcIewhDoyU5XOGPZ&q=85&s=fc230904d6b6678e79de8351a3a4d78b" alt="api_keys" width="1392" height="672" data-path="images/auth/settings_apikeys.png" />

For best practice, create a separate Maitai key per environment, then attach the provider keys you want that environment to use.

<img src="https://mintcdn.com/maitai-cbe2cd27/kcIewhDoyU5XOGPZ/images/auth/settings_edit_apikeys.png?fit=max&auto=format&n=kcIewhDoyU5XOGPZ&q=85&s=3e1119b454e44f0155e02f6c33ee4f23" alt="api_keys_edit" width="1399" height="678" data-path="images/auth/settings_edit_apikeys.png" />
