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

README.md update to reflect how to set up an OpenAI API key as an env… #1969

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,44 @@ The REST API documentation can be found on [platform.openai.com](https://platfor
pip install openai
```

## Setting OpenAI API Key

To use the OpenAI Python library, you first need to obtain an OpenAI API key and set it as an environment variable on your local computer so that the API key information is automatically loaded when making API calls. If you don't set it as an environment variable, you will need to include the API key as a parameter in your code every time you call the API.

### Windows

Run the following in the cmd prompt, replacing "your_api_key_here" with your API key:

```sh
setx OPENAI_API_KEY "your_api_key_here"
```

This will apply to future cmd prompt window, so you will need to open a new one to use that variable. You can validate that this variable has been set by opening a new cmd prompt window and typing in:

```sh
echo %OPENAI_API_KEY%
```

### macOS/Linux

Open your shell configuration file (e.g., .bashrc, .zshrc, .profile) in a text editor. For example:

```sh
nano ~/.bashrc
```

Add the following line to set your API key:

```sh
export OPENAI_API_KEY="your_api_key_here"
```

Save the file and reload your shell configuration:

```sh
source ~/.bashrc
```

## Usage

The full API of this library can be found in [api.md](api.md).
Expand Down