Rend Developers

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."}]}'

What arrives

Text
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 in delta.reasoning_content first.
  • Tool calls arrive whole, in one chunk with delta.tool_calls, after the text.
  • The last chunk before [DONE] has no choices and carries usage and search_results. It is sent after the request is settled, so its usage.cost is 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.

JSON
{ "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:

JSON
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.