Skip to main content
Five minutes from API key to your first streamed answer. The flow is four steps: exchange your API key for a JWT, list your integrations, create a chat, and send a natural-language query over the per-agent WebSocket.

Prerequisites

Before you begin, you’ll need:
  • A Trellis API key (contact your admin or Trellis support)
  • Your organization’s HMAC secret, kept on your backend
  • Your organization’s assigned agent UUID, supplied by Trellis and stored in configuration
  • A database integration configured in your Trellis organization
Keep the base hostname configurable so moving between environments is a configuration change.

Step 1: Authenticate

Exchange your API key for a JWT token. Each call needs both the user’s email and a user_key — an HMAC-derived value your backend computes from the shared secret Trellis issued you. See Authentication for the derivation algorithm and reference snippets.
Save the token from the response—you’ll use it for all subsequent requests.

Step 2: List available integrations

Find out which database integrations are available:
Response:
Note the id of the integration you want to query. Also call GET /v1/agents and confirm that your organization’s assigned agent UUID appears in the response. An organization may have a single published, org-scoped agent whose name and is_trellis_default flag are historical metadata; clients must match the configured id exactly rather than selecting by name, order, or flag.

Step 3: Create a chat

Every conversation starts with a chat_id. Create one before sending a message:
Response:
Save the id as the chat_id. Verify that the returned agent_id exactly matches your configured agent UUID before opening the WebSocket. A mismatch means the chat is bound to a different agent: stop and contact Trellis rather than silently connecting to whichever agent is marked default.

Step 4: Send a query

Chat turns stream over the per-agent WebSocket endpoint at wss://api.trellis.sh/v1/agents/{agent_id}/chats/ws. Connect (authenticating on the upgrade), send a send_message frame, and read the streamed event frames. Every turn frame is wrapped in a durable envelope — read frame["event"] and frame["data"]:
Streamed frames (excerpt):
See the WebSocket endpoint for the full protocol — envelope, interrupt, resume, and errors — and Structured Output for handling charts, tables, and panels.
You’ve successfully sent your first query to the Trellis API.

Next steps

Streaming Responses

Learn how to stream chat turns over WebSocket — envelope, interrupt, resume.

Structured Output

Handle charts, tables, and typed panels from the chat stream.

Response Feedback

Collect user feedback on AI responses.

API Reference

Explore all available endpoints.