Complete API documentation for Text2SQL Agent.
http://localhost:8000/api/v1
All /api/v1 endpoints (except /api/v1/health) require authentication.
- API key:
X-API-Key: <key> - JWT:
Authorization: Bearer <token>
Mutation/management endpoints require scopes in MUTATION_SCOPES (default: write,admin).
When the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Convert natural language to SQL with optional execution.
POST /api/v1/queryRequest Body:
{
"query": "Show me all customers from California",
"database_id": "my_database",
"execute": true,
"show_reasoning": true,
"max_rows": 100
}Response:
{
"sql": "SELECT * FROM customers WHERE state = 'California'",
"confidence": 0.95,
"execution_time_ms": 1823,
"dialect": "postgresql",
"valid_syntax": true,
"validation_status": "validated",
"results": [...],
"reasoning_trace": [
{
"step": 1,
"thought": "Need to filter customers by state",
"action": "sql_engine",
"observation": "Query executed successfully"
}
]
}Process multiple queries in one request.
POST /api/v1/query/batchStream SQL generation results in real-time.
POST /api/v1/query/streamNotes:
- SQL is generated once; when
execute=true, the generated SQL is executed directly and results are streamed in batches. - If SQL generation returns an empty string and
execute=true, aquery_errorevent is emitted and the stream ends. - Results are capped by
max_rowsand streamed in fixed-size batches (default 100 rows).
Example SSE event:
event: sql_generated
data: {"event":"sql_generated","data":{"sql":"SELECT 1","confidence":0.92},"timestamp":1734370000.0}
Validate SQL syntax and semantics without execution.
POST /api/v1/validateIssue a JWT access token using credentials configured in AUTH_USERS.
POST /api/v1/auth/tokenRequest Body:
{
"username": "admin",
"password": "change_me"
}GET /api/v1/schema/{database_id}POST /api/v1/schema/registerRetrieve detailed reasoning for a specific query.
GET /api/v1/agent/reasoning/{query_id}Retry a failed query with correction hints.
POST /api/v1/agent/retryPOST /api/v1/databasesRequest Body:
{
"database_id": "analytics",
"connection_string": "postgresql://user:pass@host/db",
"display_name": "Analytics Database",
"pool_size": 10
}GET /api/v1/databasesGET /api/v1/databases/{database_id}GET /api/v1/databases/{database_id}/healthDELETE /api/v1/databases/{database_id}GET /api/v1/databases/health/allGenerate natural language explanation of a SQL query.
POST /api/v1/explainGenerate query structure visualization.
POST /api/v1/visualizeGET /api/v1/explain/{query_id}POST /api/v1/explain/batchPOST /api/v1/examplesPOST /api/v1/examples/searchGET /api/v1/examplesGET /api/v1/examples/{example_id}
PATCH /api/v1/examples/{example_id}
DELETE /api/v1/examples/{example_id}POST /api/v1/feedbackGET /api/v1/feedbackGET /api/v1/feedback/{feedback_id}PATCH /api/v1/feedback/{feedback_id}/statusGET /api/v1/models/versionsGET /api/v1/models/versions/activePOST /api/v1/models/versionsPOST /api/v1/models/versions/{version_id}/activateGET /api/v1/healthGET /api/v1/models/infoGET /monitoring/metricsGET /api/v1/cache/statsPOST /api/v1/cache/invalidateSupports namespace invalidation for query, model, prompt, schema, inference, and validation.