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

docs(readme): update example snippets #907

Merged
merged 1 commit into from
Nov 30, 2023
Merged
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
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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"),
)


Expand Down