Translate plain-text questions into parameterized, tenant-isolated PostgreSQL queries via an intermediate JSON schema. The AI never touches raw SQL.
git clone https://github.com/palmshed/predicate.git
cd predicate
cp .env.example .env
docker-compose up --build
import requests
res = requests.post(
"http://localhost:8000/api/v1/query/compile",
headers={"X-Predicate-API-Key": "test_key_alpha"},
json={"prompt": "Show me orders over $500 from active customers"}
)
data = res.json()
print(data["compiled_sql"]) # SELECT orders.id ...
print(data["parameters"]) # ['tenant_alpha', 500, 'active']
print(data["results"]) # [{...}, {...}]
The SQL compiler generates parameterized queries in 3.6 microseconds at median, scaling to 641k queries/sec across 4 CPU cores with zero lock contention.
POST /api/v1/query/compile Translate NL to SQL and execute
POST /api/v1/export/async Queue bulk CSV export (Celery)
GET /api/v1/metrics Per-tenant analytics
GET /health Health check (db, redis, uptime)
GET /ready Readiness probe
GET /metrics Prometheus metrics
Found something unexpected? Report an issue.