Skip to main content
The same published agent that answers the phone also answers over text. There are two ways to drive a chat from your backend: the session API (durable conversations you create, message, and end) and an OpenAI-compatible completions endpoint (a drop-in for any client that already speaks the OpenAI chat shape).

Sessions

A session is a server-side conversation tied to one agent. Create it, post messages, and end it when done. History is reconstructed for you, so you can fetch the full transcript any time. Posting a message with stream: true returns Server-Sent Events (SSE) — token deltas, tool calls, and knowledge retrievals arrive as they happen, terminating with an event: done (or event: error) frame. With stream: false you get the assembled messages in one JSON response.
# Create a session, then send a streaming message
curl -X POST https://builder.flowyte.com/api/v1/chat/sessions \
  -H "Authorization: Bearer flowyte_sk_…" \
  -H "Content-Type: application/json" \
  -d '{"agentId": "AGENT_ID"}'

curl -N -X POST https://builder.flowyte.com/api/v1/chat/sessions/SESSION_ID/messages \
  -H "Authorization: Bearer flowyte_sk_…" \
  -H "Content-Type: application/json" \
  -d '{"content": "Do you deliver to 80202?", "stream": true}'

OpenAI-compatible completions

POST /chat/completions accepts the OpenAI request shape — set model to the agent’s id. Point an existing OpenAI SDK at the base URL https://builder.flowyte.com/api/v1 and it works with only a base-URL swap.
curl -X POST https://builder.flowyte.com/api/v1/chat/completions \
  -H "Authorization: Bearer flowyte_sk_…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "AGENT_ID",
    "messages": [{"role": "user", "content": "What are your hours?"}],
    "stream": true
  }'
When stream: true, this endpoint emits OpenAI-style SSE chunks (data: {choices:[{delta:…}]}) ending with data: [DONE].

In the API

ActionEndpointScope
Create a sessionPOST /chat/sessionschat:write
Get a sessionGET /chat/sessions/{id}chat:read
List messagesGET /chat/sessions/{id}/messageschat:read
Post a message (SSE when stream)POST /chat/sessions/{id}/messageschat:write
End a sessionPOST /chat/sessions/{id}/endchat:write
OpenAI-compatible completionPOST /chat/completionschat:write
These endpoints use your secret key. To put chat in a browser without exposing a secret, use a publishable key and the Embeddable Widget.