You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Streaming example for OpenAI's GPT-4o mini model (platform.openai.com) - NB this approach will not work with the AzureOpenAI service, please use the streaming-aoai.py example instead.
# NB - in the .env file, you will need to set the OPENAI_API_KEY environment variable to your OpenAI API key.
from openai import OpenAI
from dotenv import load_dotenv
load_dotenv()
client = OpenAI()
stream = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Give me a recipe for chocolate cake"}],