AI Chat API
Conversational data querying with streaming responses
The AI Chat API allows users to query operational data and standard operating procedures using plain English. It returns streaming Server-Sent Events (SSE) responses through the native assistant runtime and Vercel AI Gateway.
bearerAuthAuthorizationBearer <token>Clerk JWT token from session
application/json- body
messages*array<>threadId?stringOptional thread ID for conversation continuity
Streaming response
response?stringtext/event-streamSSE stream of AI responses
curl -X POST "https://example.com/api/assistant/chat" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{
"role": "user",
"content": "string"
}
]
}'"string"Error payloads
A failed tool or provider call never returns its own error text. Database statements, bound query values and provider credentials are stripped before the response is serialized, so an error part carries a fixed message plus a machine-readable classification:
{ "errorText": "The assistant could not complete that step. [provider_network]" }The bracketed suffix is one of provider_auth, provider_rate_limit,
provider_network, invalid_response, output_limit or unknown. Use it to
decide whether retrying can help: provider_auth and output_limit will fail
identically on a retry, while provider_rate_limit and provider_network will
not. The suffix is a stable contract; the prose before it is not.