Running the API, either by calling a parsing function from the agentic-doc library or by calling the API directly, requires an API key.

Get Your API Key

If using in the EU, get your API key here.
Get your API key on the API Key page:
  1. Go to the LandingAI Agentic tools homepage.
  2. If you haven’t already, create an account.
  3. Click the profile icon at the bottom left corner of the page.
  4. Click API Key. Navigate to API Key
  5. Click the Copy icon to copy your API key. API Key

Set Your API Key When Using the Library

There are a few methods you can use to set the API key when using the agentic-doc library, including:

Method 1: Set the API Key as an Environment Variable

Store your API key as an environment variable.
  1. Set the API key as an environment variable: Linux/macOS: One way to do this is to add the API key to your .zshrc file. (If updating this file, run source ~/.zshrc afterward.)
    export VISION_AGENT_API_KEY=your_api_key_here
    
    Windows (Command Prompt):
    set VISION_AGENT_API_KEY=your_api_key_here
    
    Windows (PowerShell):
    $env:VISION_AGENT_API_KEY="your_api_key_here"
    
  2. You do not need to add any additional code to your script to use the API key.

Method 2: Store API Key in a .env File

Use a .env file to store your API key.
  1. Create a .env file in your project root and store your API key in it:
    VISION_AGENT_API_KEY=your_api_key_here
    
  2. You do not need to add any additional code to your script to use the API key.

Method 3: Set API Key Using the ParseConfig Class

This method is only available in agentic-doc v0.3.0 and later.
You can set the API key using the ParseConfig class. This approach is also useful in environments where setting environment variables is difficult or not persistent (notebooks, scripts run via cron, etc.). For more information, go to Pass Settings with ParseConfig. For example:
from agentic_doc.config import ParseConfig
config = ParseConfig(api_key="your-api-key-here") 

Method 4: Set API Key Using the Settings Class

This method is only available in agentic-doc v0.2.10 and earlier.
If you prefer not to use environment variables or want more control, you can set the API key using the Settings class. This approach is also useful in environments where setting environment variables is difficult or not persistent (notebooks, scripts run via cron, etc.). For example:
from agentic_doc.config import settings
settings.vision_agent_api_key = "your_api_key_here"

API Key Precedence

If the API key is set using multiple methods, the the agentic-doc library uses the following order of precedence (highest to lowest):
  • Environment variable
  • .env file
  • Library configuration (in code)
The first available key found in this order will be used. All other values will be ignored.

Set Your API Key When Calling the API Directly

Include the API key in request headers. To see code samples, go to API.

Security Best Practices

  • If using a .env file: Add .env to .gitignore to prevent accidentally committing the API key to version control.
  • Do not pass the API key directly to the code, because others could see and use your API key.

Troubleshoot API Key Issues

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

.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_here
    
    # Incorrect
    VISION_AGENT_API_KEY = your_api_key_here
    

Environment Variable Issues

If you set the API key as an environmental 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:
    echo $VISION_AGENT_API_KEY  # Linux/macOS
    echo %VISION_AGENT_API_KEY%  # Windows CMD
    $Env:VISION_AGENT_API_KEY # Windows PowerShell
    
  • 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.

Wrong API Key Used

If you have multiple accounts and is using the wrong API key, the API key might be set using multiple methods and one is taking precedence over the other. To resolve this issue, check which API keys are set using each method. Example Scenario:
  1. You create an account with your personal email address and set the API as an environment variable.
  2. A few weeks later you create an account with your work email address and store the API key for that account in a .env file.
  3. When you run , it uses the first API key, because the environment variable takes precedence over the .env file.
Solution: Checking each way the API key can be set and then removing the unwanted API keys will ensure that the correct API key is used.

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:
headers = {"Authorization": f"Basic {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.
  • Restart your environment: Close and reopen your terminal, IDE, or Jupyter notebook.

Error: Illegal header value b’Basic ’

The following error occurs when running agentic-doc v0.2.10 and earlier and the API key is missing, not set correctly, or being read too late in your code.
[error  ] Error parsing document 'File name: file_namePage: #:#]' due to: Illegal header value b'Basic ' [agentic_doc.parse] (parse.py:246)
Solutions We recommend upgrading to agentic-doc v0.3.0 or later for updated API key management options. If you choose not to upgrade, try the following tips to resolve the error:
  • Set the API key before importing the library. For example, in the snippet below, the API key is set in the VISION_AGENT_API_KEY environment variable before importing anything from the library.
    import os
    # Set environment variable first
    os.environ["VISION_AGENT_API_KEY"] = "your_api_key_here"
    
    # Now import the library
    from agentic_doc.parse import parse_documents
    
  • Check that the environment variable is correct:
    echo $VISION_AGENT_API_KEY  # Linux/macOS
    echo %VISION_AGENT_API_KEY%  # Windows CMD
    $Env:VISION_AGENT_API_KEY # Windows PowerShell
    
  • Set the API key using configuration settings: Set the API key using the ParseConfig class (in v0.3.0 and later) or the Settings class (in agentic-doc v0.2.10 and earlier).