File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -26,11 +26,12 @@ pip install openai
2626The full API of this library can be found in [ api.md] ( https://www.github.com/openai/openai-python/blob/main/api.md ) .
2727
2828``` python
29+ import os
2930from openai import OpenAI
3031
3132client = OpenAI(
32- # defaults to os.environ.get("OPENAI_API_KEY")
33- api_key = " My API Key " ,
33+ # This is the default and can be omitted
34+ api_key = os.environ.get( " OPENAI_API_KEY " ) ,
3435)
3536
3637chat_completion = client.chat.completions.create(
@@ -54,12 +55,13 @@ so that your API Key is not stored in source control.
5455Simply import ` AsyncOpenAI ` instead of ` OpenAI ` and use ` await ` with each API call:
5556
5657``` python
58+ import os
5759import asyncio
5860from openai import AsyncOpenAI
5961
6062client = AsyncOpenAI(
61- # defaults to os.environ.get("OPENAI_API_KEY")
62- api_key = " My API Key " ,
63+ # This is the default and can be omitted
64+ api_key = os.environ.get( " OPENAI_API_KEY " ) ,
6365)
6466
6567
You can’t perform that action at this time.
0 commit comments