Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/StarTrail-org/PixelRAG/llms.txt

Use this file to discover all available pages before exploring further.

pixelrag serve exposes a FastAPI search server that loads a visual index into memory and answers text, image, or pre-computed-embedding queries via a simple HTTP API. It works with both locally built indexes and the pre-built Wikipedia indexes from Hugging Face, and it supports both FAISS (default) and Qdrant backends — the backend is detected automatically from the index summary.json.

Starting the server

Install the serve extra, then point the server at your index directory:
pip install 'pixelrag[serve]'
pixelrag serve --index-dir ./my_index --port 30001
The server binds to 0.0.0.0:30001 by default and starts accepting requests as soon as the model and index finish loading. All flags:
FlagDefaultDescription
--index-dir./indexDirectory containing index.faiss and summary.json
--tiles-dir./tilesDirectory with tile images
--articles-json./articles.jsonPath to articles.json with title and URL metadata
--modelQwen/Qwen3-VL-Embedding-2BEmbedding model for query encoding
--devicecpuInference device: cpu or cuda
--peft-adapterPath to a LoRA adapter directory (merged into the model at load time)
--backend(from summary.json)Vector backend: faiss or qdrant (default: read from index summary.json, else faiss)
--qdrant-urlQdrant server or Cloud URL (required when backend is qdrant)
--qdrant-api-key$QDRANT_API_KEYAPI key for Qdrant Cloud
--qdrant-client-configPath to a JSON file of QdrantClient constructor arguments
--collection(from summary.json)Qdrant collection name (default: from summary.json, else pixelrag)
--host0.0.0.0Bind address
--port30001Bind port
--render-on-demandoffRender tile images from a Kiwix ZIM on the fly — no materialized tiles directory required
--kiwix-urlhttp://localhost:30900Base URL of a running kiwix-serve (for --render-on-demand)
--zim-book(auto-derived)Kiwix book ID for /content/{book}/; auto-derived from --kiwix-url if omitted
Environment variables:
VariableDescription
PIXELRAG_INDEX_MMAP=1Memory-map the FAISS index file instead of loading it into RAM — useful for multi-100 GB indexes where startup time and resident memory both matter

Searching

Post a JSON body with a queries array. Each query object needs a text field:
curl -X POST http://localhost:30001/search \
  -H "Content-Type: application/json" \
  -d '{"queries": [{"text": "capital of France"}], "n_docs": 5}'

Response structure

A successful /search response contains a results array with one QueryResult per query. Each result holds a hits list:
{
  "results": [
    {
      "hits": [
        {
          "score": 0.912,
          "vector_id": 104832,
          "article_id": 12,
          "tile_index": 0,
          "chunk_index": 2,
          "y_offset": 2048,
          "tile_height": 1024,
          "path": "12.png.tiles/chunk_0000_02.png",
          "url": "https://en.wikipedia.org/wiki/Paris"
        }
      ]
    }
  ]
}
FieldDescription
scoreCosine similarity between the query and the retrieved chunk (higher is better)
vector_idRaw vector row ID in the FAISS index
article_idDocument index in articles.json
tile_indexWhich tile within the document (0-based)
chunk_indexWhich 1024-pixel strip within the tile (0-based)
y_offsetPixel offset from the top of the tile to this chunk
tile_heightPixel height of this chunk
pathRelative path to the tile image file
urlSource URL or file path of the document
article_pagesTile/chunk coordinates that exist on disk for this article (e.g. "0:0-8,1:0-4"), or null for on-demand indexes
image_base64Base64-encoded tile image, present only when include_images: true

Search options

All options are fields on the search request body:
OptionTypeDescription
n_docsintNumber of results to return per query (default: 10)
nprobeintFAISS nprobe override — higher values improve recall at the cost of speed
articles_onlyboolFilter out Wikipedia meta pages (Portal:, Category:, List of …, disambiguation)
departmentstringRestrict search to a subdirectory department (set during pixelrag index build)
include_imagesboolInclude base64-encoded tile images in every hit
min_tile_heightintExclude chunks shorter than this height — filters out partial or blank tiles at page bottoms
instructionstringOverride the default query embedding instruction sent to the model
department is a pre-filter that runs inside FAISS via an IDSelector (or as a payload filter in Qdrant), not a post-filter. This means you always get the full n_docs results as long as the department has enough indexed tiles.

Hosted Wikipedia API

api.pixelrag.ai serves a pre-built index of 8.28M Wikipedia pages. No authentication is required — send the same search payload you would send to a local server:
curl -X POST https://api.pixelrag.ai/search \
  -H "Content-Type: application/json" \
  -d '{"queries": [{"text": "What is the capital of France?"}], "n_docs": 5}'
Check whether the hosted API is reachable:
curl https://api.pixelrag.ai/status
The hosted endpoint also accepts image queries — pass "image" with a base64-encoded PNG or JPEG just as you would against a local server.

Build docs developers (and LLMs) love