ChatDev: ValueError: OpenAI API key not found - but it shows as environment variable (Arch)
I started a fresh ArchCraft installation in VM to test ChatDev, installed all that’s needed, cloned repository, using venv instead of conda for environment, activated environment, installed requirements and exported OPENAI_API_KEY as environment variable, i can even see it correctly displayed among other env variables running command env.
But then running sudo python3 run.py --task "task description here" --name " name here"
run the script properly till “Note that we must ONLY discuss the product modality and do not discuss …” paragraph, then it hangs for some second and return an error:
tenacity.RetryError: RetryError[<Future at 0x7f00af522790 state=finished raised ValueError>]
The error is caused by another error: ValueError: OpenAI API key not found. raised in /home/username/.personal/ChatDev/camel/utils.py
What am I doing wrong? Is it because I am not using conda?
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Comments: 15 (3 by maintainers)
Hello everyone, Not sure if this is helpful, so I resolved my issues with the “ValueError: OpenAI API key not found” by updating the “run.py” file.
I’m on a linux system and I tried the (export OPENAI_API_KEY=“your_OpenAI_API_key”) including adding it to my “.bashrc” file but with no luck.
After some testing, here’s what I found and added into the “run.py” file: import os import openai os.environ[“OPENAI_API_KEY”] = “YOUR API KEY” openai.api_key = “YOUR API KEY”
This is working so far. I’ve tested it and it works for my instance.
Hope that helps. Thanks again! 😃
I had the same problem using google colab. This worked:
import os os.environ[“OPENAI_API_KEY”] = “YOUR API KEY”
Hello!
Thank you very much for your attention and efforts with ChatDev. I’d like to point out that currently, our ChatDev software requires you to configure your own OpenAI API key, as outlined in our STEP 4. You may want to double-check if you’ve completed this step correctly for it to work effectively.
Given your situation, I believe we can provide you with a testing key: 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 (with a small balance allocated exclusively for testing purposes).