HTTP server (autorag.api)

FastAPI app behind the autorag serve command. Exposes /health, /ingest, /query, and — when the [rag] extra is installed — the /viz page and /viz/data / /viz/search endpoints. The static viz bundle is mounted at /viz-assets and is served from autorag.viz.viz_assets_dir. With the [broker] extra the async /jobs/audio (POST) / /jobs/{id} / /jobs/{id}/result endpoints are added; without it they return 503 and the rest of the API is unaffected. See Running the HTTP server for the async-pipeline walkthrough.

FastAPI server for AutoRAG.

Wraps autorag.core.AutoRAG behind HTTP endpoints. Mount this app with autorag serve or any ASGI runner.

Endpoints:

  • GET /health — liveness probe.

  • POST /ingest — document ingestion (see IngestRequest).

  • POST /query — RAG query (see QueryRequest).

When the [rag] extra is installed, the /viz page, its JSON endpoints (/viz/data, /viz/search), and the React asset mount at /viz-assets are added on top. A [server]-only install silently skips them.

The async job API (POST /jobs/audio, GET /jobs/{id}, GET /jobs/{id}/result) is added unconditionally but degrades gracefully: it returns 503 with an install hint when the [broker] / [rag] extras the worker path needs are absent. The synchronous endpoints above never touch the broker.

autorag.api.app

The FastAPI application instance. Importable as autorag.api:app.

autorag.api.get_rag()[source]

Return a process-wide AutoRAG singleton.

Cached so request handlers reuse the same vector store / embedder instead of re-instantiating per call.

Return type:

AutoRAG

autorag.api.health()

Liveness probe. Always returns {"status": "ok"}.

Return type:

dict[str, str]

autorag.api.ingest(req)

Load, chunk, embed, and store the documents referenced by req.paths.

Parameters:

req (IngestRequest)

Return type:

IngestResponse

autorag.api.query(req)

Retrieve relevant chunks and generate an answer for req.question.

Parameters:

req (QueryRequest)

Return type:

QueryResponse

autorag.api.submit_job(req)

Enqueue an audio→topics job. Returns 202 + job_id at once.

503 when the [broker] / [rag] extras are not installed (MissingExtraError is an ImportError).

Parameters:

req (AudioJobRequest)

Return type:

JobSubmitResponse

autorag.api.job_status(job_id)

Return the job’s status + per-stage state. 404 if unknown.

Parameters:

job_id (str)

Return type:

JobRecord

autorag.api.job_result(job_id)

Return the finished clip (the existing SQLite row).

404 if unknown, 409 if the job is not yet done.

Parameters:

job_id (str)

Return type:

JobResultResponse

The Pydantic request/response models (QueryRequest, IngestRequest, etc.) are documented in Types, schemas, config, formatting.