Streaming
Receive the answer as server-sent events while it is written.
Set stream to true on any of the three APIs to receive server-sent events as the answer is written. The Python examples continue from the client set up on Chat Completions or Messages.
Stream any request that may take longer than 5 minutes. A non-streaming request that runs longer may be cut off, while a streamed response stays open for up to an hour as long as data keeps arriving, though a server deployment can end it earlier; see Timeouts.
stream = client.chat.completions.create(
model="raon-1-mini",
messages=[{"role": "user", "content": "Hello!"}],
stream=True,
stream_options={"include_usage": True},
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)- On Chat Completions,
stream_options.include_usageadds token usage in a final chunk. - With curl, add
-Nso the output is not buffered.

