EXA API KEY Error

Getting the ERROR EXA_API_KEY not set. Please set the EXA_API_KEY environment variable. I did set the EXA key multiple times, but keep getting this error. Created a new key on EXA and still the same issue. Any ideas why I am getting this error? Machine is a Windows 11 laptop.

Hi @rajurs ,
Thank you for reaching out and using Phidata! I’ve tagged the relevant engineers to assist you with your query. We aim to respond within 24 hours.
If this is urgent, please feel free to let us know, and we’ll do our best to prioritize it.
Thanks for your patience!

Hey @rajurs , can you try logging you api_key to console to check if api key is set.
use echo %EXA_API_KEY%

Alternatively you can directly pass your api_key into the tool.

here is an example

from phi.agent import Agent, RunResponse  # noqa
from phi.model.openai import OpenAIChat
from phi.tools.exa import ExaTools

agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    markdown=True,
    tools=[ExaTools(api_key="bffe.....your_api_key.....")],
    debug_mode=True,
)

agent.print_response("Share a 2 sentence horror story, search the web for the first sentence")

Will try and let you know. Thanks

For some unknown reason, PowerShell was not setting the EXA API Key, no matter how many times I executed the Setx command. Ended up hardcoding it and that worked.

Thanks for the input. I have been playing around with Agentic FXs for a bit now and love what PhiData is doing! Great product.

1 Like