Streaming
from openai import OpenAI
client = OpenAI(api_key="OXYGEN_API_KEY",base_url="https://app.oxyapi.uk/v1")
stream = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Say this is a test"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")Parsing Server-sent events
Last updated