What AI Features Do
ChartDB’s AI capabilities include:DDL Export
Generate DDL scripts in any database dialect for migrations
Smart Conversion
Convert schemas between MySQL, PostgreSQL, SQLite, SQL Server, etc.
Dialect Translation
Translate database-specific syntax to your target platform
Schema Optimization
Get suggestions for schema improvements and best practices
AI features are completely optional. ChartDB works perfectly without AI for schema visualization and manual editing.
Option 1: OpenAI API
The simplest way to enable AI features is using OpenAI’s API.Get an API Key
Create OpenAI Account
Sign up at platform.openai.com
Configure ChartDB
- Docker Runtime
- Docker Build
- NPM Development
- NPM Build
Pass the API key when running the container:
Recommended: Runtime configuration keeps secrets out of images
Test the Configuration
If AI features aren’t working, check the browser console (F12) for error messages about the API key.
Option 2: Self-Hosted LLM
For complete data privacy or to avoid API costs, use a self-hosted LLM inference server.Supported Inference Servers
Any server compatible with OpenAI’s API format will work:- vLLM
- Ollama
- LocalAI
- LM Studio
High-performance inference server optimized for throughput.Installation:Run Server:Configure ChartDB:
vLLM is excellent for high-throughput scenarios and supports many quantization formats (AWQ, GPTQ, etc.)
Recommended Models
For DDL generation and schema conversion, these models work well:| Model | Size | Quality | Speed | Memory |
|---|---|---|---|---|
| Qwen 2.5 32B | 32B | Excellent | Medium | 20GB+ |
| Qwen 2.5 14B | 14B | Very Good | Fast | 10GB+ |
| Qwen 2.5 7B | 7B | Good | Very Fast | 6GB+ |
| Llama 3.1 70B | 70B | Excellent | Slow | 40GB+ |
| Llama 3.1 8B | 8B | Good | Very Fast | 6GB+ |
| Mistral 7B | 7B | Good | Very Fast | 6GB+ |
Use quantized models (AWQ, GPTQ, or GGUF) to reduce memory requirements. A 32B AWQ model can run in ~20GB RAM instead of 64GB.
Configuration Examples
Complete vLLM Setup
Ollama with Docker Compose
docker-compose.yml
Network Configuration
When running both the LLM server and ChartDB in Docker:- Linux
- Mac/Windows
- Docker Compose
Use
--network host for simplest setup:Hybrid Setup
You can switch between OpenAI and self-hosted LLMs by changing environment variables:AI Feature Usage
Once configured, use AI features in ChartDB:Choose Target Database
Select your target database dialect:
- PostgreSQL
- MySQL
- SQL Server
- MariaDB
- SQLite
- CockroachDB
- ClickHouse
Troubleshooting
AI features not appearing
AI features not appearing
Cause: Environment variables not set correctlySolution:Ensure you’re using the correct variable names (no
VITE_ prefix for runtime).Cannot connect to inference server
Cannot connect to inference server
Cause: Network configuration or incorrect endpointSolution:Verify the endpoint is accessible from the ChartDB container.
Model not found error
Model not found error
Cause: Model name doesn’t match what’s loaded in the serverSolution:
Slow or timeout errors
Slow or timeout errors
Cause: Model is too large or not enough resourcesSolution:
- Use a smaller/quantized model (7B instead of 32B)
- Increase memory allocation for Docker
- Use GPU acceleration if available
- Increase timeout in your inference server
Poor quality DDL output
Poor quality DDL output
Cause: Model too small or not suited for code generationSolution:
- Use larger models (14B+ recommended)
- Try Qwen 2.5 series (optimized for code)
- Ensure model supports instruction following
- Check if quantization is too aggressive (Q4 vs Q8)
- Qwen 2.5 32B Instruct (AWQ)
- Qwen 2.5 14B Instruct
- Llama 3.1 70B Instruct
Mixed configuration error
Mixed configuration error
Cause: Both OpenAI and custom endpoint configuredSolution:
Performance Optimization
Hardware Requirements
For self-hosted LLMs:| Model Size | RAM Required | GPU Memory | Speed |
|---|---|---|---|
| 7B (Q4) | 6 GB | 4 GB | Fast |
| 7B (Q8) | 8 GB | 6 GB | Fast |
| 14B (AWQ) | 10 GB | 8 GB | Medium |
| 32B (AWQ) | 20 GB | 16 GB | Medium |
| 70B (AWQ) | 40 GB | 32 GB | Slow |
AWQ and GPTQ quantization provide the best quality-to-size ratio. Q4 is fast but lower quality.
Optimization Tips
Use Quantization
AWQ or GPTQ models offer 2-3x memory reduction with minimal quality loss
GPU Acceleration
Use
--gpus all with vLLM or enable GPU in LM Studio for 10-50x speedupBatch Inference
vLLM automatically batches requests for better throughput
Model Caching
Keep models loaded in memory to avoid reload overhead
Security & Privacy
Self-hosted LLMs provide complete data privacy:Benefits of Self-Hosting:
- Schema data never leaves your network
- No external API calls
- Full audit trail
- No usage limits or costs
- Compliance with data regulations (GDPR, HIPAA, etc.)
Cost Comparison
| Option | Setup Cost | Running Cost | Privacy | Performance |
|---|---|---|---|---|
| OpenAI API | Free | ~$0.01-0.10 per request | ⚠️ Data sent to OpenAI | Fast (API latency) |
| Self-hosted (CPU) | Free | ~$0.50/hr server cost | ✅ Complete privacy | Slow (CPU inference) |
| Self-hosted (GPU) | $500-5000 hardware | ~$0.10-1.00/hr electricity | ✅ Complete privacy | Fast (GPU inference) |
| Cloud GPU (AWS/GCP) | Free | ~$1-5/hr instance cost | ⚠️ Data in cloud | Fast (GPU inference) |
For occasional use, OpenAI API is most cost-effective. For frequent use or privacy requirements, self-hosted is better.
Next Steps
Docker Deployment
Learn how to deploy ChartDB with Docker
Configuration
Explore all configuration options
