Skip to main content

Configuration

Ragpi uses the following environment variables to configure its behavior. These settings control everything from API access and provider configurations to database connections and document processing.

Application Configuration

VariableDescriptionDefaultNotes
PROJECT_NAMEName of the projectthe current projectUsed to scope and focus the AI assistant's responses
PROJECT_DESCRIPTIONDescription of the projectdetermined by the available sourcesDefines the project's scope for the AI assistant
RAGPI_VERSIONAPI version of Ragpiv0.5.xUsed in the OpenAPI spec and in docker-compose.prod.yml to specify the Ragpi image version
API_NAMEName of the API serviceRagpiUsed in the OpenAPI spec
API_SUMMARYSummary of the API serviceRagpi is an AI assistant specialized in retrieving and synthesizing technical information to provide relevant answers to queries.Used in the OpenAPI spec
RAGPI_API_KEYAPI key for authenticated requestsNoneIf not set, the API will be accessible without authentication. When set, this key must be a self-generated secret and included in the x-api-key header of each request.
WORKERS_ENABLEDEnable/disable background workersTrueWhen disabled, endpoints requiring Celery workers will return a 503
TASK_RETENTION_DAYSNumber of days to retain task history7-
LOG_LEVELLogging levelINFOOptions: DEBUG, INFO, WARNING, ERROR, CRITICAL
USER_AGENTUser agent string for HTTP requestsRagpi-
MAX_CONCURRENT_REQUESTSMaximum number of concurrent requests10-

Provider Configuration

VariableDescriptionDefaultNotes
CHAT_PROVIDERChat service provideropenaiOptions: openai,ollama,deepseek,openai_compatible
EMBEDDING_PROVIDEREmbedding service provideropenaiOptions: openai,ollama,openai_compatible
OPENAI_API_KEYAPI key for OpenAI servicesNoneRequired if using openai as chat/embedding provider
OLLAMA_BASE_URLBase URL for Ollama providerNoneRequired if using ollama as chat/embedding provider
DEEPSEEK_API_KEYAPI key for DeepSeek servicesNoneRequired if using deepseek as chat provider
CHAT_OPENAI_COMPATIBLE_BASE_URLBase URL for OpenAI-compatible chat modelsNoneRequired if using openai_compatible as chat provider
CHAT_OPENAI_COMPATIBLE_API_KEYAPI key for OpenAI-compatible chat modelsNoneRequired if using openai_compatible as chat provider
EMBEDDING_OPENAI_COMPATIBLE_BASE_URLBase URL for OpenAI-compatible embedding modelsNoneRequired if using openai_compatible as embedding provider
EMBEDDING_OPENAI_COMPATIBLE_API_KEYAPI key for OpenAI-compatible embedding modelsNoneRequired if using openai_compatible as embedding provider

Database Configuration

VariableDescriptionDefaultNotes
REDIS_URLRedis connection URLredis://localhost:6379Required
POSTGRES_URLPostgreSQL database URLpostgresql://localhost:5432/ragpiRequired if using postgres backend
DOCUMENT_STORE_BACKENDDocument store backend (postgres, redis)postgres-
DOCUMENT_STORE_NAMESPACENamespace for document storagedocument_storeWhen using postgres, this is the table name; when using redis, it is the key prefix.
SOURCE_METADATA_BACKENDMetadata storage backend (postgres, redis)postgres-
SOURCE_METADATA_NAMESPACENamespace for metadata storagesource_metadataWhen using postgres, this is the table name; when using redis, it is the key prefix.

Chat Settings

VariableDescriptionDefault
BASE_SYSTEM_PROMPTDefault system prompt for the AI assistantSee below
CHAT_HISTORY_LIMITMaximum number of messages retained in the chat history and sent to the model.20
MAX_CHAT_ITERATIONSMaximum steps allowed for generating a response5
RETRIEVAL_TOP_KNumber of top retrieval results10

Model Settings

VariableDescriptionDefaultNotes
DEFAULT_CHAT_MODELDefault model for chat interactionsgpt-4oOnly models that support tool/function callings are supported.
CHAT_USE_RESPONSES_APIUse the OpenAI Responses API for chatFalseRequires CHAT_PROVIDER=openai. Needed for OpenAI reasoning models (e.g. gpt-5.6-sol, gpt-5.6-terra) to combine active reasoning with tool calling. See Reasoning Models.
REASONING_EFFORTDefault reasoning effort for reasoning modelsNoneOptions: none, minimal, low, medium, high, xhigh, max. Only sent when set and only on the Responses API path; can be overridden per request via reasoning_effort. Not every model supports every value (GPT-5.6 does not support minimal).
OPENAI_RESPONSES_STOREStore Responses API state with OpenAITrueResponses API path only. True is the only supported value today — False (required for Zero Data Retention) is reserved for future work and currently fails startup when the Responses path is enabled. See the privacy note under Reasoning Models.
EMBEDDING_MODELModel used for embeddingstext-embedding-3-small-
EMBEDDING_DIMENSIONSDimensions for embedding vectors1536Must match dimensions of selected embedding model. Dimensions above 2000 (e.g. text-embedding-3-large at 3072) are supported — see Large Embedding Models. Changing this on an existing deployment requires re-embedding.
EMBEDDING_CANDIDATE_MULTIPLIERCandidate over-fetch factor for the >2000-dimension retrieval path10Candidates fetched per search = RETRIEVAL_TOP_K × this value, then reranked by exact full-precision cosine. Postgres backend only; no effect at ≤2000 dimensions.
HNSW_EF_SEARCHLower bound for pgvector's hnsw.ef_search during candidate fetchNone11000. Only affects >2000-dimension searches that PostgreSQL serves via the HNSW index; when unset, derived from the candidate count.
EMBEDDING_SPACE_IDExplicit embedding-space identity recorded in the store manifestNoneOnly needed for ollama/openai_compatible embedding providers where a model alias can change meaning without the endpoint URL changing. When unset, derived from the provider/endpoint.
EMBEDDING_ADOPT_EXISTINGAllow adopting a pre-existing store that has no manifestFalseOnly needed when upgrading an existing deployment that uses a non-default embedding configuration. Set once for the first startup after upgrading, then remove.
PG_UPDATE_VECTOR_EXTENSIONRun ALTER EXTENSION vector UPDATE at startupFalseOnly needed when an existing PostgreSQL database has a pgvector extension older than required. Upgrades the extension for the entire database — back up and check other pgvector-dependent applications first.

Reasoning Models (OpenAI Responses API Only)

OpenAI reasoning models (such as gpt-5.6-sol and gpt-5.6-terra) cannot combine active reasoning with tool calling on the Chat Completions API. To use them with Ragpi's retrieval tools, enable the Responses API path:

CHAT_PROVIDER=openai
DEFAULT_CHAT_MODEL=gpt-5.6-sol
CHAT_USE_RESPONSES_API=true
REASONING_EFFORT=low

When CHAT_USE_RESPONSES_API is off (the default), all providers use the Chat Completions API exactly as before. Reasoning continuity is preserved across the tool-call loop within a single chat request. reasoning_effort may also be set per request in the /chat payload.

Privacy

The Responses API path sends store=true, meaning conversation state is retained in OpenAI's stored-responses workflow for at least 30 days to support reasoning continuity across tool calls. Using store=false, as required for Zero Data Retention, is not yet supported.

Large Embedding Models

text-embedding-3-large is supported at its full 3072 dimensions:

EMBEDDING_MODEL=text-embedding-3-large
EMBEDDING_DIMENSIONS=3072

On the PostgreSQL backend, embeddings are always stored as full-precision float32. Above 2000 dimensions (pgvector's index limit for the vector type) Ragpi builds a half-precision (halfvec) HNSW index and reranks candidates by exact full-precision cosine. This requires the pgvector server extension ≥ 0.8.2 (the pgvector/pgvector:pg17 image satisfies it; for an older extension in an existing database, see PG_UPDATE_VECTOR_EXTENSION). The Redis backend supports 3072 dimensions without additional configuration.

Note that PostgreSQL chooses the access path per query: for small and medium sources it typically serves the candidate stage with a sequential scan and switches to the HNSW index only when a source grows large enough for it to win on cost. EMBEDDING_CANDIDATE_MULTIPLIER controls the number of candidates on both paths, while HNSW_EF_SEARCH only influences queries served by the index.

Ragpi records a manifest for each document store (embedding provider, model, dimensions, and index configuration) and validates it at startup, failing fast with actionable guidance on an incompatible change. Note that changing the embedding model requires re-embedding even when the dimensions stay the same.

Changing the Embedding Model or Dimensions in an Existing Ragpi Deployment

Changing the embedding identity (provider, model, or dimensions) requires re-embedding all documents; there is no automatic data migration:

  1. Back up the database / Redis data, then stop the API and workers.
  2. Remove the document vectors and the store manifest, keeping source metadata:
    • PostgreSQL: DROP TABLE <DOCUMENT_STORE_NAMESPACE>; and delete its row from ragpi_store_manifest (leave the source_metadata table intact).
    • Redis: drop the index, delete its <namespace>:sources:* keys, and delete the <namespace>:__manifest__ key.
  3. Restart with the new EMBEDDING_MODEL / EMBEDDING_DIMENSIONS (startup recreates the schema, index, and manifest), then re-sync every source.

Document Processing

VariableDescriptionDefault
DOCUMENT_UUID_NAMESPACEUUID namespace for document IDsee747eb2-fd0f-4650-9785-a2e9ae036ff2
CHUNK_SIZESize of document chunks for processing (in tokens)512
CHUNK_OVERLAPOverlap size between document chunks (in tokens)50
DOCUMENT_SYNC_BATCH_SIZENumber of documents processed per batch during sync500

GitHub

VariableDescriptionDefault
GITHUB_TOKENGitHub token used by GitHub connectorsNone
GITHUB_API_VERSIONGitHub API version2022-11-28

OpenTelemetry Settings

VariableDescriptionDefault
OTEL_ENABLEDEnable/disable OpenTelemetryFalse
OTEL_SERVICE_NAMEService name for OpenTelemetryragpi
OTEL_EXPORTER_OTLP_ENDPOINTOpenTelemetry collector endpointhttp://localhost:4318

When enabled, Ragpi provides basic tracing capabilities through OpenTelemetry instrumentation using the http/protobuf protocol. This includes automatic tracing of FastAPI endpoints and LLM API calls, with spans exported to the endpoint specified in OTEL_EXPORTER_OTLP_ENDPOINT.

Additionally, Ragpi respects any standard OTEL environment variables (e.g., OTEL_RESOURCE_ATTRIBUTES, OTEL_EXPORTER_OTLP_HEADERS, etc.) supported by the OpenTelemetry specification.

Default System Prompt

The default value for BASE_SYSTEM_PROMPT is:

You are an AI assistant specialized in retrieving and synthesizing technical information to provide relevant answers to queries.

API Key Configuration

If you want to restrict access to the Ragpi API, you can enable API authentication using RAGPI_API_KEY. When set, this key must be included in all API requests using the x-api-key header.

Generating an API Key

You can generate a secure API key using the following command in your terminal:

openssl rand -hex 32