Guides
Streaming
Send “stream”: true and the reply arrives as server-sent events while the model writes it, in the OpenAI chunk format.
Example
curl -N https://api.rend.ai/v1/chat/completions \
-H "Authorization: Bearer $REND_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "rend-swift", "stream": true, "messages": [{"role": "user", "content": "Write a 30-second ad script for running shoes."}]}'stream = client.chat.completions.create(
model="rend-swift",
messages=[{"role": "user", "content": "Write a 30-second ad script for running shoes."}],
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="", flush=True)
elif getattr(chunk, "usage", None):
print("\ncost (USD):", chunk.usage.model_extra["cost"])const stream = await client.chat.completions.create({
model: "rend-swift",
messages: [{ role: "user", content: "Write a 30-second ad script for running shoes." }],
stream: true,
});
for await (const chunk of stream) {
if (chunk.choices.length) process.stdout.write(chunk.choices[0].delta.content ?? "");
else if (chunk.usage) console.log("\ncost (USD):", chunk.usage.cost);
}What arrives
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"rend-swift","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"rend-swift","choices":[{"index":0,"delta":{"content":"Open on"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"rend-swift","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","model":"rend-swift","choices":[],"usage":{"prompt_tokens":18,"completion_tokens":640,"cost":0.001361,...},"search_results":[]}
data: [DONE]- The first chunk goes out as soon as the model starts, even while it is still thinking, so you know the reply is under way.
- Text arrives in
delta.content. With"include_reasoning": true, thinking arrives indelta.reasoning_contentfirst. - Tool calls arrive whole, in one chunk with
delta.tool_calls, after the text. - The last chunk before
[DONE]has no choices and carriesusageandsearch_results. It is sent after the request is settled, so itsusage.costis exactly what you were charged.
Search progress
When search is on, chunks with an empty choices and a rend_search field report each search as it starts and finishes. OpenAI clients skip them; show them if you want a live “searching” line.
{ "object": "chat.completion.chunk", "choices": [],
"rend_search": { "status": "searching", "type": "web", "query": "best running shoes 2026" } }status is searching, then done (with results) or failed.
Errors while streaming
An error before the model starts comes back as a normal HTTP error with a JSON body. An error after the stream has begun arrives as a final event:
data: {"error":{"message":"...","type":"api_error","code":null}}Cancelling
Close the connection to stop the model. You pay for what ran up to that point. A reader that stops reading for 60 seconds is treated as gone.
Video takes
GET /v1/videos/{id}/events streams a video take’s progress the same way, ending with video.completed or video.failed. Closing it does not stop the take. See Follow a take live.