Skip to main content
CosmiQ exposes a documented REST API with interactive Swagger/OpenAPI docs (/docs) so you can embed it into any product or workflow. Every endpoint operates on the same Spaces and verified-query library used by the chat UI and the MCP tool.

Authentication

All endpoints require a Bearer JWT. The chat UI’s Chainlit session cookie (access_token) and the REST API share the same underlying session, so a token issued for one works for the other.

Endpoints

POST /query

Ask a question against a Space and get back a complete answer — natural-language response, the generated SQL, and execution metadata.

POST /query/stream

Identical inputs to POST /query, but returns newline-delimited JSON (NDJSON) so the answer can be streamed token-by-token — the same mechanism the chat UI uses.

POST /api/bootstrap/space

Probes a set of Pinot tables (schema, config, and a sample of live data) and drafts a first-pass Space: column descriptions, synonyms, inferred relationships, business rules tagged by confidence, and a handful of starter verified queries. Uses Claude Opus by default for the generation step. The result is a draft — review it via PATCH /api/spaces/{id} before relying on it.

GET /api/spaces

Lists all Spaces visible to the authenticated principal.

PATCH /api/spaces/

Edits an existing Space’s tables, business rules, relationships, query policy (including do_not_use columns and row/timeout limits), or verified queries.

POST /api/feedback

Records a 👍/👎 rating for a specific answer. Highly-rated answers with working SQL are surfaced by GET /api/feedback/suggestions as candidates for promotion into the Space’s verified-query library.

GET /api/feedback/suggestions

Returns up-voted answers that are good candidates to promote into a Space’s verified-query library.

MCP tool

CosmiQ also exposes a text_to_sql MCP tool that wraps the same agent used by POST /query. See How to Use CosmiQ for setup.

Defaults reference

These govern query and agent behavior across all access methods (chat UI, MCP tool, REST API). All settings except the models are configurable per Space via its query policy.

CosmiQ Overview

What CosmiQ is, how Spaces work, and the deployment architecture behind these endpoints.

How to Use CosmiQ

Chat UI and MCP tool walkthroughs, and the Getting Started steps.

Security and Compliance

Read-only guarantees, data handling, and access controls.