Streaming & Tool Calling
Streaming Chat (SSE)
The token is generated and returned at the same time, without waiting for a complete response.
python
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NEXEVO_API_KEY"],
base_url="https://api.nexevo.ai/v1",
)
stream = client.chat.completions.create(
model="deepseek-chat",
messages=[{"role": "user", "content": "Write a haiku about TypeScript"}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content or ""
print(delta, end="", flush=True)