Skip to main content
Convert natural-language questions into SQL with live progress updates. The endpoint emits Server-Sent Events (SSE) so you can render status updates and final SQL in real time.
Rate limit: 20 requests per minute per API key. The mode field toggles between query_writer (default) and analyst, which adds commentary and requires an Exa key for enrichment.

Request fields

message
string
required
User prompt or question.
mode
string
default:"query_writer"
Either query_writer for SQL only or analyst for SQL plus narrative analysis.
conversation_history
array
Optional prior turns to maintain context. Supply objects with role and content fields.

Example SSE Stream

data: {"type":"plan","payload":{"step":"Analyzing schema for polymarket_events"}}

data: {"type":"plan","payload":{"step":"Building SQL query with filters"}}

data: {"type":"sql","payload":{"query":"SELECT title, yes_probability, volume_24hr FROM polymarket_events WHERE active = true ORDER BY volume_24hr DESC LIMIT 10"}}

data: {"type":"final","payload":{"query_id":"550e8400-e29b-41d4-a716-446655440000","sql":"SELECT title, yes_probability, volume_24hr FROM polymarket_events WHERE active = true ORDER BY volume_24hr DESC LIMIT 10"}}

Stream handling

  • Each SSE event is emitted as data: .
  • Watch for type=final to retrieve the generated SQL and an execution-ready query ID.
  • Treat type=error events as terminal; the connection closes immediately afterward.
Pair this endpoint with POST /api/query to run the generated SQL automatically once the stream completes.