Skip to main content
Relay accepts the output your agent already produces. Send one request with stream=true and pipe a Vercel AI SDK UIMessageStream v1 into its body. Relay consumes the whole stream and commits one canonical message when it finishes. There is no Relay draft to open, append, edit, or clean up.

Pipe an AI SDK response

Use the conversation_id from message.received and derive the idempotency key from that event’s event_id.
This is a direct HTTPS integration, not a Relay SDK. Your backend still owns the model, tool loop, prompts, memory, and hosting.

Wire request

The same contract can be exercised without a framework:
reply.sse uses the AI SDK’s existing framing:
Relay returns the normal 202 message response after the canonical commit.

What Relay preserves

The external agent owns the full loop. Relay is the messaging channel and presentation surface.

Completion and recovery

  • finish is semantic completion. [DONE] only closes the transport; it does not commit a message by itself.
  • abort, error, malformed ordering, or an early disconnect writes no transcript row.
  • A successful stream produces one durable message.created event and one notification.
  • Retry the whole request with the same Idempotency-Key. The same completed stream returns the original message; different content returns 409 idempotency_conflict.
  • A disconnected app recovers the final message through normal cursor sync and history.
Use a separate typing indicator before the output stream begins when the agent has a long planning or tool phase.

Next steps