Skip to main content
Trinity
API Reference

Chat API

API endpoints for agent chat, voice, streaming, and public chat access. All endpoints require JWT Bearer token unless noted. See Authentication for details.

Full interactive API docs are available at http://localhost:8000/docs when running locally.

Authenticated Chat

POST

/api/agents/:name/chat

Send a message to an agent. Returns stream-json output for real-time responses.

curl -X POST -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"message": "Summarize the latest research findings"}' \
  http://localhost:8000/api/agents/research-agent/chat
GET

/api/agents/:name/chat/sessions

List all chat sessions for an agent.

GET

/api/agents/:name/chat/sessions/:id

Get a specific session with all its messages.

POST

/api/agents/:name/chat/sessions/:id/close

Close a chat session.

GET

/api/agents/:name/chat/history/persistent

Get persistent chat history across sessions.

DELETE

/api/agents/:name/chat/history

Reset the current chat session.

GET

/api/agents/:name/activity

Get an activity summary for the agent.

Voice Chat

POST

/api/agents/:name/voice/start

Start a voice chat session with an agent.

POST

/api/agents/:name/voice/stop

Stop a voice chat session.

GET

/api/agents/:name/voice/status

Get the current voice session status.

WS

/api/agents/:name/voice/ws

WebSocket endpoint for bidirectional audio streaming. Used as the audio bridge for voice chat.

Public Chat (No Auth)

Public chat endpoints do not require authentication. They use a unique token to identify the public chat session.

POST

/api/public/chat/:token

Send a message via public chat using a share token.

GET

/api/public/history/:token

Get chat history for a public chat session.

Paid Chat (x402)

Paid chat endpoints use the x402 payment protocol. Clients receive a 402 response with payment requirements, then resubmit with a payment proof header.

POST

/api/paid/:agent_name/chat

Send a paid chat message. Returns 402 with payment requirements or 200 with the response.

GET

/api/paid/:agent_name/info

Get payment requirements and pricing info for an agent.

Task Execution

POST

/api/agents/:name/task

Submit a task for asynchronous execution. Tasks are queued and executed by the agent.

curl -X POST -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"message": "Generate a report on Q1 sales data"}' \
  http://localhost:8000/api/agents/research-agent/task
GET

/api/agents/:name/executions

List all executions (tasks and schedule runs) for an agent.

GET

/api/agents/:name/executions/:id

Get full details of a specific execution including response, errors, and tool calls.

Endpoint Summary

EndpointMethodDescription
/api/agents/{name}/chatPOSTSend message (stream-json output)
/api/agents/{name}/chat/sessionsGETList sessions
/api/agents/{name}/chat/sessions/{id}GETSession with messages
/api/agents/{name}/chat/sessions/{id}/closePOSTClose session
/api/agents/{name}/chat/history/persistentGETPersistent history
/api/agents/{name}/chat/historyDELETEReset session
/api/agents/{name}/activityGETActivity summary
/api/agents/{name}/voice/startPOSTStart voice session
/api/agents/{name}/voice/stopPOSTStop session
/api/agents/{name}/voice/statusGETSession status
/api/agents/{name}/voice/wsWSAudio WebSocket bridge
/api/public/chat/{token}POSTPublic chat
/api/public/history/{token}GETPublic history
/api/paid/{agent_name}/chatPOSTPaid chat (402/200)
/api/paid/{agent_name}/infoGETPayment requirements
/api/agents/{name}/taskPOSTSubmit task
/api/agents/{name}/executionsGETList executions
/api/agents/{name}/executions/{id}GETExecution details