Skip to content

Commit

Permalink
Headers
Browse files Browse the repository at this point in the history
  • Loading branch information
daveebbelaar committed Apr 20, 2023
1 parent 66c173b commit fee11a8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ First, create a `.env` file in the root directory of the project. Inside the fil
OPENAI_API_KEY=your_api_key_here
```

Save the file and close it.

In your Python script or Jupyter notebook, load the `.env` file using the following code:
Save the file and close it. In your Python script or Jupyter notebook, load the `.env` file using the following code:
```python
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
```

By using the right naming convention for the environment variable, you don't have to manually store the key in a separate variable and pass it to the function. The library or package that requires the API key will automatically recognize the `OPENAI_API_KEY` environment variable and use its value.

When needed, you can access the `OPENAI_API_KEY` as an environment variable:
#### 5. When needed, you can access the `OPENAI_API_KEY` as an environment variable:
```python
import os
api_key = os.environ['OPENAI_API_KEY']
Expand Down

0 comments on commit fee11a8

Please sign in to comment.