Rendley docs

Streaming agent sessions

The automated editing page covers the simple fire-and-poll flow. This page covers the streaming alternative: instead of polling a job, you open an SSE (Server-Sent Events) connection and receive the agent’s responses in real time. This gives you token-by-token output and interactive control when the agent wants a decision.

Use the streaming API when you want to show live progress to your users, or when you need to approve or reject the agent’s plan before it runs.

For unattended batch processing where you don’t need real-time feedback, the simpler automated editing flow is usually the better choice.

Overview

The streaming flow has three concepts:

  • Project. Holds the timeline and media. Created with POST /v1/projects.
  • Thread. A conversation history tied to a project. Lets the agent keep context across multiple prompts.
  • Session. A single agent run within a thread. You send a prompt, the agent streams back its response, and the project gets edited.

#Step 1: Create a project and thread

POST/v1/agent/threads

First, create a project (or use an existing one), then open a thread on it.

Save the returned thread_id. You can also fetch the most recent thread for a project with GET /v1/agent/threads/last?project_id=....

#Step 2: Start a session

POST/v1/agent/sessions

Send your prompt as message. The response is a text/event-stream, not JSON, so read it as a stream.

#Step 3: Read the stream

GET/v1/agent/sessions

The stream emits named events. Keep reading until you get completed (success) or error.

EventMeaning
tokenA chunk of the agent’s text reply. data is { "content": "..." }.
token_doneThe text reply is finished.
interruptThe agent is pausing for a decision (see step 4).
completedThe agent finished. The project is now edited.
errorThe agent stopped. data carries the reason.

#Step 4: Handle interrupts

POST/v1/agent/sessions/resume

The agent may pause and emit an interrupt event when it wants your input. Common reasons:

  • Plan approval. The agent shows what it intends to do and waits for your OK.
  • Paid action approval. An action that costs credits needs confirmation.
  • Clarification. The agent needs more information to continue.

Resume the agent by posting to the resume endpoint, then read the new stream the same way.

response can be "approve", "reject", or free text answering the agent’s question. For an unattended backend, auto-approve every interrupt to let the agent run to completion.

Step 5: Export

When the session completes, the project is edited but not yet rendered. Export it and poll the job to get a downloadable file.

Continuing a conversation

To send follow-up prompts, start another session on the same thread. The agent keeps the full context of previous edits:

curl -N -X POST https://api.rendley.com/v1/agent/sessions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "thread_id": "THREAD_ID",
    "project_id": "PROJECT_ID",
    "message": "Make the intro shorter and add a call-to-action at the end."
  }'