Skip to main content

REST API — raglight serve

raglight serve starts a FastAPI server that exposes your RAG pipeline as a REST API. The entire configuration is driven by environment variables — no Python code required.
The interactive API documentation (Swagger UI) is automatically available at http://localhost:8000/docs once the server is running.

Quick start

The server starts on http://0.0.0.0:8000 by default and prints the active configuration on startup.

CLI options


Chat UI — --ui

Add --ui to start a Streamlit chat interface alongside the API. Both processes share the same configuration and communicate over HTTP.
The UI lets you:
  • Chat with your documents — full conversation history, markdown rendering
  • Upload files directly from the browser (PDF, TXT, code…)
  • Ingest a directory by providing a path on the server machine
  • Switch LLM on the fly — the ⚙️ Model settings panel in the sidebar lets you change provider, model, and API base URL without restarting the server
Use --ui-port to change the Streamlit port:
The API and UI run as two independent processes. Stopping raglight serve terminates both cleanly.

Configuration

All settings are read from RAGLIGHT_* environment variables. Copy the example file and adjust the values:
Valid provider values match the Settings constants:
  • LLM: Ollama, Mistral, OpenAI, LmStudio, GoogleGemini, AWSBedrock
  • Embeddings: HuggingFace, Ollama, OpenAI, GoogleGemini, AWSBedrock

Example: Mistral + remote Chroma

.env

Endpoints

GET /health

Returns the server status.

POST /generate

Ask a question to the RAG pipeline. Request body
Response

POST /ingest

Index documents into the vector store. Supports three sources — combinable in a single call. Request body
All fields are optional, but at least one must be provided.

POST /ingest/upload

Upload files directly from the client via multipart/form-data. Use this when the server and the files are on different machines. The field name must be files. Multiple files can be sent in a single request.
Uploaded files are written to a temporary directory, processed, indexed into ChromaDB, then deleted. Nothing is stored permanently on disk besides the embeddings. Response

GET /collections

List the available ChromaDB collections.

GET /config

Returns the currently active LLM configuration.

POST /config

Switches the LLM at runtime — no server restart required. The new model is loaded immediately and used for all subsequent /generate calls. Request body
This is the endpoint used by the Streamlit UI’s ⚙️ Model settings panel.

Deploy with Docker Compose

The fastest path to a production deployment:
1

Copy the example env file

Edit .env and set your LLM provider, model, and any API keys.
2

Start the stack

The API is available at http://localhost:8000.
3

Ingest your documents

4

Query the API

The docker-compose.yml includes extra_hosts: host.docker.internal:host-gateway so the container can reach an Ollama instance running on the host machine.

Summary