Environment Variables
ChartDB uses Vite for building, which means environment variables are handled differently at build time versus runtime.Build-Time vs Runtime
- Build Time
- Runtime
Build-time variables are embedded into the compiled JavaScript during the build process. They are prefixed with
VITE_:Build-time configuration is permanent and cannot be changed without rebuilding the application.
Configuration Options
AI Configuration
Configure AI features for DDL script generation and intelligent operations.OpenAI API Key
Use OpenAI’s GPT models for AI features:| Variable | Type | Description |
|---|---|---|
OPENAI_API_KEY | string | Your OpenAI API key (starts with sk-) |
VITE_OPENAI_API_KEY | string | Build-time version |
Custom Inference Server
Use a custom LLM inference server compatible with OpenAI’s API format:| Variable | Type | Description |
|---|---|---|
OPENAI_API_ENDPOINT | string | Custom inference server URL (must end with /v1) |
VITE_OPENAI_API_ENDPOINT | string | Build-time version |
LLM_MODEL_NAME | string | Model identifier for the custom server |
VITE_LLM_MODEL_NAME | string | Build-time version |
Supported LLM Servers
ChartDB works with any OpenAI-compatible API. Popular options include:vLLM
High-performance inference server for large language models
LocalAI
Drop-in replacement API for running LLMs locally
Ollama
Easy-to-use local LLM server with OpenAI-compatible endpoints
LM Studio
Desktop application for running LLMs with API server
UI Configuration
Hide ChartDB Cloud
Remove references to ChartDB Cloud for a fully self-hosted experience:| Variable | Type | Default | Description |
|---|---|---|---|
HIDE_CHARTDB_CLOUD | boolean | false | Hides ChartDB Cloud branding and links |
VITE_HIDE_CHARTDB_CLOUD | boolean | false | Build-time version |
- ChartDB Cloud promotional banners
- Links to the hosted version
- Cloud-specific UI elements
Analytics Configuration
Disable Analytics
ChartDB includes privacy-focused analytics via Fathom Analytics. You can disable this:| Variable | Type | Default | Description |
|---|---|---|---|
DISABLE_ANALYTICS | boolean | false | Completely disables Fathom Analytics |
VITE_DISABLE_ANALYTICS | boolean | false | Build-time version |
ChartDB uses Fathom Analytics, which is privacy-focused and GDPR compliant. No personal data is collected. However, you can disable it entirely for internal deployments.
Internal Configuration
These variables are used internally and generally don’t need to be changed:| Variable | Type | Description |
|---|---|---|
VITE_IS_CHARTDB_IO | boolean | Identifies the official ChartDB.io deployment |
VITE_APP_URL | string | Application URL for canonical links |
VITE_HOST_URL | string | Host URL for API requests |
Configuration Examples
Minimal Setup
Basic ChartDB deployment without AI features:OpenAI Integration
Full-featured setup with OpenAI:Self-Hosted with Local LLM
Complete self-hosted setup with local vLLM:Enterprise Setup
Production-ready configuration:docker-compose.yml
Configuration File Reference
package.json Scripts
ChartDB’spackage.json includes several build and development scripts:
Dockerfile Build Arguments
The Dockerfile accepts these build arguments:Nginx Configuration
ChartDB uses a custom Nginx configuration template that dynamically injects environment variables:Environment Variable Loading
ChartDB loads environment variables in the following order (later sources override earlier ones):Code Reference
Environment variables are loaded insrc/lib/env.ts:
Notice how
HIDE_CHARTDB_CLOUD and DISABLE_ANALYTICS check window.env first (runtime) before falling back to import.meta.env (build-time). This enables Docker runtime configuration.Validation
Check Current Configuration
Verify your configuration is loaded correctly:Debug Configuration Issues
Variables not taking effect
Variables not taking effect
Ensure you’re using the correct variable names:
- Build time: Use
VITE_prefix with--build-arg - Runtime: No prefix with
-eflag
src/lib/env.ts:1-15 to see how variables are loaded.AI features not working
AI features not working
Verify your AI configuration:Remember: Use either
OPENAI_API_KEY or OPENAI_API_ENDPOINT + LLM_MODEL_NAME, not both.Build-time variables not working
Build-time variables not working
Ensure you’re using
--build-arg (not -e) and the VITE_ prefix:Security Considerations
Best Practices
Use runtime environment variables
Prefer runtime configuration over build-time for sensitive values:
Restrict API key permissions
Create API keys with minimal required permissions for ChartDB’s AI features
Next Steps
Docker Deployment
Learn how to deploy ChartDB with Docker
AI Setup
Detailed guide to configuring AI features
