Skip to main content
  1. 1
    Set up your API key

    Get your API key from the Exa Dashboard and set it as an environment variable.

    Create a file called .env in the root of your project and add the following line:

    EXA_API_KEY=your api key without quotes
    
  2. 2
    Install the SDK

    Install the Python SDKs with pip. If you want to store your API key in a .env file, make sure to install the dotenv library.

    pip install exa-py
    pip install openai
    pip install python-dotenv
    
  3. 3
    Create your code

    Once you’ve installed the SDKs, create a file called exa.py and add the code below.

    Get a list of results and their full text content.

    python
    from exa_py import Exa
    from dotenv import load_dotenv
    
    import os
    
    # Use .env to store your API key or paste it directly into the code
    load_dotenv()
    exa = Exa(os.getenv('EXA_API_KEY'))
    
    result = exa.search(
      "An article about the state of AGI",
      type="auto",
      contents={
        "text": True
      }
    )
    
    print(result)