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.2.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.
EMBEDDING_MODELModel used for embeddingstext-embedding-3-small-
EMBEDDING_DIMENSIONSDimensions for embedding vectors1536Must match dimensions of selected embedding model

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