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

# API Key

> Get or regenerate your API key, track credit usage by key, create credit alerts, and set the key for the libraries or direct API calls.

Calling the Agentic Document Extraction API requires an API key.

* [Get your API key](#get-your-api-key)
* [Regenerate your Personal API Key](#regenerate-your-personal-api-key)
* [Track usage by API key](#track-usage-by-api-key)
* [Get credit alerts](#get-credit-alerts)
* [Set your API key when using a library](#set-your-api-key-when-using-a-library)
* [Set your API key when calling the API directly](#set-your-api-key-when-calling-the-api-directly)

## Get Your API Key

\[!NOTE] If using Agentic Document Extraction in the EU, get your API key [here](https://ade.eu-west-1.landing.ai/settings/api-key).
Copy your API key from the **API** view on the home page:

1. Log in to [https://ade.landing.ai/](https://ade.landing.ai/).
2. On the home page, click **API** in the **Playground** | **API** switcher under the page title.

   ![ADE home page with API selected in the Playground and API switcher under the title](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-home-api-switcher.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=908c3c50e84a69884aa9f27d30b75123)
3. Click **Copy** next to your API key. The card shows the API key you created most recently. If the card says **No API key yet**, click **Create API Key** to create one. If you use a personal account (Explore plan), click **Check All API Keys** and copy the key on the API Key page.

   ![API view on the home page with the Copy button next to the API key highlighted](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-home-copy.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=ec557bdafa8525fa70ab5cef2937833b)

To see every API key in your organization, go to the [API Key](https://ade.landing.ai/settings/api-key) page: click **Check All API Keys** in the **API** view, or click **API Keys** under **Admin** in the left sidebar. You can copy only the API keys you created.

![Left sidebar with API Keys under Admin highlighted](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-sidebar-api-keys.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=1dbce03a5bb87d33ff3e916414cfef8b)

## Regenerate Your Personal API Key

If your Personal API Key is exposed or leaked, regenerate it. Regenerating creates a new key and invalidates the current one, and it can't be undone. Update every place that uses the old key, such as the `VISION_AGENT_API_KEY` environment variable.

To regenerate your Personal API Key:

1. Log in to [https://ade.landing.ai/](https://ade.landing.ai/).
2. Go to the [API Key](https://ade.landing.ai/settings/api-key) page (to navigate there manually, click **API Keys** under **Admin** in the left sidebar).
3. In the **Personal API Key** row, click the **Regenerate Personal API Key** icon (the circular arrow next to the **Copy** icon).

   ![Personal API Key row with the Regenerate Personal API Key icon highlighted](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-regenerate-icon.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=bb3880aa88086c5d0546978141d38ddf)
4. Click **Regenerate** to confirm.

   ![Regenerate Personal API Key confirmation with the Regenerate button highlighted](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-regenerate-dialog.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=40a4f2e9ceb994fa651f8e7512344d11)
5. Click the **Copy** icon to copy the new key.

## Track Usage by API Key

In an organization account, the Usage page shows how many credits each API key uses. For everything on the Usage page, see [Monitor Credit Usage](https://docs.landing.ai/ade/monitor-usage.md).

To track usage by API key:

1. Log in to [https://ade.landing.ai/](https://ade.landing.ai/).
2. Click **Usage** under **Admin** in the left sidebar.
3. In **Group by**, select **API key**. The chart splits each day's credits by API key.

   ![Usage page with Group by set to API key, showing daily credits split by key](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-usage-group-by.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=99b7968d6d6f74e7df536abf57c458c4)
4. To see the usage of one API key, select it in the **API key** filter. The credit and request totals update to that key.

## Get Credit Alerts

Credit alerts email the people you choose when your organization's credit usage crosses a threshold. Alerts are available on the Team and Enterprise plans. Only Admins can create, edit, and delete alerts.

To create a credit alert:

1. On the **Usage** page, scroll to **Alert** and click **Create Alert**.

   ![Usage page scrolled to the Alert section with the Create Alert button highlighted](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-usage-create-alert.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=f37c0c66b1d05c3c2993e1e90d050596)
2. In **Alert threshold**, enter a number and select the unit: **Credits**, **USD**, or **% of quota**.
3. In **Recipients**, add up to 20 members to email.
4. (Optional) Enter a label.
5. Click **Create alert**.

   ![Create Alert pop-up on the Usage page with the Alert threshold set to 75% of quota](https://mintcdn.com/landingaitest/NKnyPQxI7aWZaFcB/images/api-key-usage-alert.png?fit=max\&auto=format\&n=NKnyPQxI7aWZaFcB\&q=85\&s=050e831d109c8be0c262590d97e9dfa3)

Alerts are checked hourly and sent once per billing period. For default alerts and alert statuses, see [Credit Usage Alerts](https://docs.landing.ai/ade/credit-alerts.md).

## Set Your API Key When Using a Library

The Python and TypeScript libraries read your API key from the `VISION_AGENT_API_KEY` environment variable. For installation and other ways to set the key, see the [Python](https://docs.landing.ai/dpt3/ade-python.md) or [TypeScript](https://docs.landing.ai/dpt3/ade-typescript.md) library page. Set the key before running your code:

```bash macOS/Linux theme={null}
export VISION_AGENT_API_KEY="<your-api-key>"
```

```cmd Windows (Command Prompt) theme={null}
set "VISION_AGENT_API_KEY=<your-api-key>"
```

```powershell Windows (PowerShell) theme={null}
$env:VISION_AGENT_API_KEY="<your-api-key>"
```

## Set Your API Key When Calling the API Directly

Include the API key in request headers. To see code samples, go to [API](https://docs.landing.ai/api-reference/parse/ade-parse.md).

## Security Best Practices

* Do not hard-code the API key in your source code, because others could see and use your API key. Passing a variable that holds the key (for example, from a secrets manager) is fine.

## Troubleshoot API Key Issues

Use the troubleshooting tips in this section to resolve issues related to API keys.

### Error: Missing API Key

If no API key is set by any method, the library raises an error when you create the client.

The Python library raises this error:

```text theme={null}
landingai_ade.LandingAiadeError: The apikey client option must be set either by passing apikey to the client or by setting the VISION_AGENT_API_KEY environment variable
```

The TypeScript library throws this error:

```text theme={null}
LandingAIADEError: The VISION_AGENT_API_KEY environment variable is missing or empty; either provide it, or instantiate the LandingAIADE client with an apikey option, like new LandingAIADE({ apikey: 'My Apikey' }).
```

To resolve this issue, set the key using one of the supported methods. If you set the key in a `.env` file or as an environment variable and still get this error, see the .env File Issues and Environment Variable Issues sections.

### .env File Issues

If you set the API key in the `.env` file but the environment variable is not loading, try these possible solutions to resolve this issue:

* Check file location: The `.env` file should be in the same directory where you run your script.
* Verify file format: No spaces around the equals sign:
  ```
  # Correct
  VISION_AGENT_API_KEY=<your-api-key>

  # Incorrect
  VISION_AGENT_API_KEY = <your-api-key>
  ```

### Environment Variable Issues

If you set the API key as an environment variable and are encountering issues, try these possible solutions to resolve this issue:

* Restart your application after setting environment variables.
* Check variable name: Must be exactly `VISION_AGENT_API_KEY`.
* Check if the environment variable is correct:

  ```bash macOS/Linux theme={null}
  echo $VISION_AGENT_API_KEY
  ```

  ```cmd Windows (Command Prompt) theme={null}
  echo %VISION_AGENT_API_KEY%
  ```

  ```powershell Windows (PowerShell) theme={null}
  $env:VISION_AGENT_API_KEY
  ```
* Ensure that you apply the changes after setting, changing, or removing the environment variable:
  * **Linux/macOS**: Restart your terminal. If you added the variable to your `.zshrc` file, run `source ~/.zshrc`.
  * **Windows**: Close and reopen Command Prompt/PowerShell, or restart your IDE.

### Error: Missing Authorization Header

This error occurs if the authorization header is not included when calling the API directly. To fix this, include the API header:

```python theme={null}
headers = {"Authorization": f"Bearer {api_key}"}
```

### Error: User Not Found, Please Check Your API Key

This error occurs when the API key is entered incorrectly.

To resolve this issue:

* Verify the API key: Copy your key directly from the [dashboard](https://ade.landing.ai/settings/api-key).
* Restart your environment: Close and reopen your terminal, IDE, or Jupyter notebook.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.