Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error) #14

Open
arcturien opened this issue May 7, 2023 · 8 comments

Comments

@arcturien
Copy link

It seems like the .env file I've copy-pasted from AutoGpt is not working.

Questions :
1 - Where is the template for the .env file ?
2 - How to pass the openai_api_key while running ChromeGPT ?

Thanks in advance.

@Tomazazs
Copy link

Tomazazs commented May 7, 2023

in cmd.
$Env:OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxx"

@arcturien2
Copy link

Thanks a lot,

I'll test this tomorrow !!!

@arcturien
Copy link
Author

Oops, I got this error, any other option?

Error: Got unexpected extra argument ($Env:OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxx)

Thanks in advance.

@arcturien
Copy link
Author

Got it !!!

In the following article I can see that the key can be set in sys var (Windows).
https://korben.info/chrome-gpt-controle-session-chrome-auto-gpt-langchain.html

@p6002
Copy link

p6002 commented May 28, 2023

in cmd. $Env:OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxx"

:OPENAI_API_KEY=: command not found

@p6002
Copy link

p6002 commented May 28, 2023

I use Ubuntu Server 22

@arcturien
Copy link
Author

You can ask ChatGPT :

To add an environment variable on Ubuntu Server 22, you can follow these steps:

  1. Open a terminal on your Ubuntu Server.

  2. Run the following command to open the .bashrc file in a text editor:

    nano ~/.bashrc
  3. In the text editor, scroll to the end of the file and add the following line:

    export OPENAI_API_KEY="your_api_key_here"

    Replace "your_api_key_here" with your actual OpenAI API key.

  4. Press Ctrl+O to save the file, and then press Enter to confirm the filename.

  5. Press Ctrl+X to exit the text editor.

At this point, the OPENAI_API_KEY environment variable is added to your .bashrc file. However, to make it effective in the current terminal session, you need to run the following command:

source ~/.bashrc

Now, the OPENAI_API_KEY environment variable is available for the current session. You can access it in your scripts or use it directly in the terminal.

If you want the environment variable to be available globally for all users and across all sessions, you can add it to the /etc/environment file instead of the .bashrc file. However, modifying the global environment variables may require administrative privileges.

Remember to keep your API key secure and avoid sharing it publicly or committing it to version control repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants