NL2SQL API
FastAPI REST service for the NL2SQL engine (nl2sql-engine). It builds one
NL2SQL engine at startup, from the same env file and configs as the CLI, and
serves it under /api/v1.
Running the API
pip install nl2sql-api
ENV=demo NL2SQL_API_ROLE=admin nl2sql-api --host 127.0.0.1 --port 8000 [--reload]
# or: python -m nl2sql_api.server ..., or: uvicorn nl2sql_api.main:app
Start it from the folder holding the env file and configs (the demo's use
relative paths). Interactive docs: Swagger UI at /docs, ReDoc at /redoc,
the schema at /openapi.json.
The API does not authenticate callers and never takes the RBAC role from the
request body. Set one of: NL2SQL_API_ROLE_HEADER (a header a trusted proxy
sets), NL2SQL_API_ROLE (one static role) or, for local testing only,
NL2SQL_API_TRUST_BODY_ROLE=true (the body's user_context; logs a warning).
With none, /api/v1/query and /api/v1/query/stream answer HTTP 401.
The routes that change datasources, LLMs or the index need a role listed in
NL2SQL_API_ADMIN_ROLES (default admin), else HTTP 403. With no role setting
at all they answer loopback clients only.
Endpoints
POST /api/v1/query- Ask a question as the configured rolePOST /api/v1/query/stream- The same, as Server-Sent Events: each step as it runs, the result manifest, the answer as it is written, then the/queryresponseGET /api/v1/health- Liveness checkGET /api/v1/ready- Readiness check (does not yet check dependencies)POST /api/v1/datasource- Register a datasource in the running processGET /api/v1/datasource- List registered datasource idsGET /api/v1/datasource/{datasource_id}- Check a datasource is registeredDELETE /api/v1/datasource/{datasource_id}- Not supported yet (answerssuccess: false)POST /api/v1/llm- Configure an LLM in the running processGET /api/v1/llm- List configured LLMsGET /api/v1/llm/{llm_name}- Get one configured LLMPOST /api/v1/index/{datasource_id}- Index one datasource's schemaPOST /api/v1/index-all- Index every registered datasourceDELETE /api/v1/index- Clear the vector storeGET /api/v1/index/status- Index health (status, entries by type, embedding model, problems)
Reference: https://github.com/nadeem4/nl2sql/blob/main/docs/api/rest/index.md.
Metadata
Release files for nl2sql-api 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nl2sql_api-0.4.1.tar.gz | 24.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nl2sql_api-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.9 kB
Release files / nl2sql_api-0.4.1.tar.gz
| Download URL | nl2sql_api-0.4.1.tar.gz |
|---|---|
| Size | 24.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
390a384e09917553eefc57662f38d6a1711955cd59f2e1b95b9f0ad5bd9fe16a
|
|
BLAKE2b-256 checksum How to use checksums |
ab39d07f580b97c3be82979b483d831fddbb01b5cbda6896858d69f2c85e84ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / nl2sql_api-0.4.1-py3-none-any.whl
| Download URL | nl2sql_api-0.4.1-py3-none-any.whl |
|---|---|
| Size | 19.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
59ba6039f11dda618fae828ecaff931c2526294b12dbe2f357a7c191937d5fdf
|
|
BLAKE2b-256 checksum How to use checksums |
d9a69e23bf4550f6ec1bce8a8c501904b759a11e45cff8ce07dbdf3cee6d12d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|