gpt-engineer icon indicating copy to clipboard operation
gpt-engineer copied to clipboard

Issue with the OpenAI API key

Open nithinreddyyyyyy opened this issue 2 years ago • 24 comments

export is not working in windows. And I tried set too, it is also not working. Can you please let me know how to deal with this?

nithinreddyyyyyy avatar Jun 18 '23 16:06 nithinreddyyyyyy

try to use set instead of export

MomenMM avatar Jun 18 '23 16:06 MomenMM

try to use set instead of export

I have used set as well. It is not working...

nithinreddyyyyyy avatar Jun 18 '23 16:06 nithinreddyyyyyy

+1

ELHARAKA avatar Jun 18 '23 17:06 ELHARAKA

Same here. Can't set API key. Also tried using $env with no luck.

nigelp avatar Jun 18 '23 17:06 nigelp

Can anyone please look into this?

nithinreddyyyyyy avatar Jun 18 '23 17:06 nithinreddyyyyyy

Can you share the specific commands you are running?

JosemyDuarte avatar Jun 18 '23 17:06 JosemyDuarte

Can you share the specific commands you are running?

Tried both

set OPENAI_API_KEY=KEY set: OPENAI_API_KEY=KEY

nithinreddyyyyyy avatar Jun 18 '23 18:06 nithinreddyyyyyy

Should consider re-opening #136 as it would solve these issues for all platforms

EnzoMartin avatar Jun 18 '23 18:06 EnzoMartin

Open discussion about this in #135

Please go there and add your opinions to raise visibility and then maybe get it introduced.

patillacode avatar Jun 18 '23 18:06 patillacode

Can you share the specific commands you are running?

Tried both

set OPENAI_API_KEY=KEY set: OPENAI_API_KEY=KEY

try $env:OPENAI_API_KEY="<API-KEY>" on Windows

kenna avatar Jun 19 '23 01:06 kenna

set it via openai.api_key = "blablabla" inside gpt_engineer/main.py. Remember to import openai

augusto-rehfeldt avatar Jun 19 '23 03:06 augusto-rehfeldt

try to use set instead of export

I have used set as well. It is not working...

same, Having issues my self, I did notice I could not find the file that imports the OPENAI key I believe its supposed to be main.py? I will have to do some more digging make sure I am not over looking something or doing it wrong. If I figure out something on my end I will try to remember to post it.

Jgreen42 avatar Jun 21 '23 20:06 Jgreen42

Same issue here:

File "C:\xxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 66, in app()

File "C:\xxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 47, in main ai = AI(

File "C:\xxxxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\ai.py", line 15, in init openai.Model.retrieve(model)

File "C:\xxxxxxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\openai\api_resources\abstract\api_resource.py", line 20, in retrieve
instance.refresh(request_id=request_id, request_timeout=request_timeout)

File "C:\xxxxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\openai\api_resources\abstract\api_resource.py", line 32, in refresh self.request(

File "C:\xxxxxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\openai\openai_object.py", line 172, in request requestor = api_requestor.APIRequestor(

File "C:\xxxxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\openai\api_requestor.py", line 138, in init self.api_key = key or util.default_api_key()

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\openai\util.py", line 186, in default_api_key raise openai.error.AuthenticationError(

openai.error.AuthenticationError: No API key provided. You can set your API key in code using 'openai.api_key = <API-KEY>', or you can set the environment variable OPENAI_API_KEY=<API-KEY>). If your API key is stored in a file, you can point the openai module at it with 'openai.api_key_path = <PATH>'. You can generate API keys in the OpenAI web interface. See https://platform.openai.com/account/api-keys for details.

ligarius avatar Jun 22 '23 00:06 ligarius

Agree with this answer, I guess Powershell was used by default nowadays. (If you see something like (venv) PS C:\Projects\AI\gpt-engineer> in your terminal, 'PS` stands for powershell)

Q: in windows powershell, how to set env variable?

ChatGPT: To set an environment variable in Windows PowerShell, you can use the $env automatic variable to access and modify the environment variables. Here's how you can set an environment variable:

$env:VariableName = "VariableValue"

Replace VariableName with the name of the environment variable you want to set, and VariableValue with the desired value.

For example, to set an environment variable named OPENAI_API_KEY with the value sk-x...., you would use the following command:

$env:OPENAI_API_KEY= "sk-x...."

Can you share the specific commands you are running?

Tried both set OPENAI_API_KEY=KEY set: OPENAI_API_KEY=KEY

try $env:OPENAI_API_KEY="" on Windows

liusida avatar Jun 22 '23 03:06 liusida

on windows works with $env:OPENAI_API_KEY='sk-xxx' but now I get openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details using the (free) GPT 3.5 key

EdwardDali avatar Jun 22 '23 08:06 EdwardDali

using $env:OPENAI_API_KEY="" on Windows

INFO:openai:error_code=model_not_found error_message="The model 'gpt-4' does not exist" error_param=model error_type=invalid_request_error message='OpenAI API error received' stream_error=False Model gpt-4 not available for provided API key. Reverting to gpt-3.5-turbo. Sign up for the GPT-4 wait list here: https://openai.com/waitlist/gpt-4-api Traceback (most recent call last):

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 66, in app()

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 61, in main messages = step(ai, dbs)

File "C:\xxxxxl\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\steps.py", line 30, in clarify messages = [ai.fsystem(dbs.identity["qa"])]

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\db.py", line 18, in getitem raise KeyError(key)

KeyError: 'qa'

ligarius avatar Jun 22 '23 12:06 ligarius

using $env:OPENAI_API_KEY="" on Windows

INFO:openai:error_code=model_not_found error_message="The model 'gpt-4' does not exist" error_param=model error_type=invalid_request_error message='OpenAI API error received' stream_error=False Model gpt-4 not available for provided API key. Reverting to gpt-3.5-turbo. Sign up for the GPT-4 wait list here: https://openai.com/waitlist/gpt-4-api Traceback (most recent call last):

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 66, in app()

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 61, in main messages = step(ai, dbs)

File "C:\xxxxxl\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\steps.py", line 30, in clarify messages = [ai.fsystem(dbs.identity["qa"])]

File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\db.py", line 18, in getitem raise KeyError(key)

KeyError: 'qa'

When I used $env:OPENAI_API_KEY="KEYGOESHERE" on Windows and placing the key in where I put "KEYGOESHERE", it works for me. however, you are getting that error because you do not have GPT-4 API access yet. Sign up for the waiting list. You may want to change the model to 3.5 in the code, and then try too.

kenna avatar Jun 22 '23 13:06 kenna

using $env:OPENAI_API_KEY="" on Windows INFO:openai:error_code=model_not_found error_message="The model 'gpt-4' does not exist" error_param=model error_type=invalid_request_error message='OpenAI API error received' stream_error=False Model gpt-4 not available for provided API key. Reverting to gpt-3.5-turbo. Sign up for the GPT-4 wait list here: https://openai.com/waitlist/gpt-4-api Traceback (most recent call last): File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 66, in app() File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\main.py", line 61, in main messages = step(ai, dbs) File "C:\xxxxxl\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\steps.py", line 30, in clarify messages = [ai.fsystem(dbs.identity["qa"])] File "C:\xxxxx\Proyectos\GPTe\GPTe\gpt_engineer\myenv\lib\site-packages\gpt_engineer\db.py", line 18, in getitem raise KeyError(key) KeyError: 'qa'

When I used $env:OPENAI_API_KEY="KEYGOESHERE" on Windows and placing the key in where I put "KEYGOESHERE", it works for me. however, you are getting that error because you do not have GPT-4 API access yet. Sign up for the waiting list. You may want to change the model to 3.5 in the code, and then try too.

Hi

I have GPT4 membershitp

ligarius avatar Jun 22 '23 13:06 ligarius

if set doesn't work on windows just delete spaces before and after '='

Unessc0 avatar Jun 22 '23 13:06 Unessc0

try to use set instead of export

I have used set as well. It is not working...

Does not work

MeMyselfAndAI2023 avatar Jun 26 '23 20:06 MeMyselfAndAI2023

if set doesn't work on windows just delete spaces before and after '='

Does not work either

MeMyselfAndAI2023 avatar Jun 26 '23 20:06 MeMyselfAndAI2023

win search -> Edit the system environment variables -> Environment Variables... -> New...

1nspir3d avatar Jul 03 '23 20:07 1nspir3d

win search -> Edit the system environment variables -> Environment Variables... -> New...

I tried this a while ago, but even this didn‘t work for me. Did it do the job for you, after you set the api-key as an environment variable?

MeMyselfAndAI2023 avatar Jul 03 '23 22:07 MeMyselfAndAI2023

win search -> Edit the system environment variables -> Environment Variables... -> New...

I tried this a while ago, but even this didn‘t work for me. Did it do the job for you, after you set the api-key as an environment variable?

while it did a job with making it visible for the gpt-engineer I have another problem now.

when I have a prompt file w/o extension command fails with openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.

however when I have prompt.txt filled in with my prompt it fails with AssertionError: Please put your prompt in the file 'prompt' in the project directory

1nspir3d avatar Jul 03 '23 23:07 1nspir3d

Info about this in readme now

AntonOsika avatar Jul 12 '23 12:07 AntonOsika

$env:OPENAI_API_KEY= "sk-x...."

This is the only solution that worked! Thanks!

icemusike avatar Jul 25 '23 05:07 icemusike