gpt-engineer
gpt-engineer copied to clipboard
exporting the api key to the environment doesn't work for me
I can't get the export command to work, so an alternative solution like using an extern file or hardcoding the api in the code would be a nice solution. I personally created an external json config file and parsed the api key from that to the python script.
So a solution could be:
- Make a json file named "config.json"
- Inside of ai.py add:
import json
def get_api_key(file_name: str) -> str:
with open(file_name, 'r') as f:
config = json.load(f)
return config['openai_api_key']
- Inside of config.json add:
{
"openai_api_key": "your_api_key"
}
- In the init part of the AI class add:
class AI:
def __init__(self, **kwargs):
openai.api_key = get_api_key("config.json")
self.kwargs = kwargs
I created a PR where this issue can be resolved using .env variables. Please leave a comment under there if you think that would resolve your issue.
https://github.com/AntonOsika/gpt-engineer/pull/22
that solved my issue, thanks
that solved my issue, thanks
i fixed my problem by using set: OPENAI_API_KEY= instead of export worked for me =)
I created a PR where this issue can be resolved using .env variables. Please leave a comment under there if you think that would resolve your issue.
#22
This worked for me on windows 11
Open discussion about this in #135
If you wish to reopen the issue please do following the new issue template.