From bbb648ef81eb11f81b457e2cbf33a832f4d29a76 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Thu, 30 Nov 2023 08:20:46 -0500 Subject: [PATCH] docs(readme): update example snippets (#907) --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 380ccc58d..4cabdb897 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,12 @@ pip install openai The full API of this library can be found in [api.md](https://www.github.com/openai/openai-python/blob/main/api.md). ```python +import os from openai import OpenAI client = OpenAI( - # defaults to os.environ.get("OPENAI_API_KEY") - api_key="My API Key", + # This is the default and can be omitted + api_key=os.environ.get("OPENAI_API_KEY"), ) chat_completion = client.chat.completions.create( @@ -54,12 +55,13 @@ so that your API Key is not stored in source control. Simply import `AsyncOpenAI` instead of `OpenAI` and use `await` with each API call: ```python +import os import asyncio from openai import AsyncOpenAI client = AsyncOpenAI( - # defaults to os.environ.get("OPENAI_API_KEY") - api_key="My API Key", + # This is the default and can be omitted + api_key=os.environ.get("OPENAI_API_KEY"), )