Configure AI providers for natural language query generation in CQLAI.
| Provider | Models | Best For |
|---|
| OpenAI | GPT-4, GPT-4 Turbo, GPT-3.5 Turbo | Best accuracy |
| Anthropic | Claude 3 Opus, Sonnet, Haiku | Complex reasoning |
| Azure OpenAI | GPT-4, GPT-3.5 | Enterprise compliance |
| AWS Bedrock | Claude, Titan | AWS integration |
| Google Vertex AI | Gemini Pro | Google Cloud |
| Ollama | Llama 3, Mixtral, etc. | Local/private |
| OpenAI-compatible | Various | Custom endpoints |
export CQLAI_AI_PROVIDER=openai
export CQLAI_AI_KEY=sk-...
cqlai --ai-provider openai --ai-key sk-...
# key from CQLAI_AI_KEY environment variable
| Model | Speed | Accuracy | Cost |
|---|
| gpt-4-turbo | Fast | Highest | $$$$ |
| gpt-4 | Slow | Highest | $$$$ |
| gpt-3.5-turbo | Fastest | Good | $ |
export CQLAI_AI_PROVIDER=anthropic
export CQLAI_AI_KEY=sk-ant-...
model: claude-3-sonnet-20240229
| Model | Speed | Accuracy | Cost |
|---|
| claude-3-opus | Slow | Highest | $$$$ |
| claude-3-sonnet | Fast | High | $$ |
| claude-3-haiku | Fastest | Good | $ |
export CQLAI_AI_PROVIDER=azure
export CQLAI_AI_KEY=your-azure-key
export CQLAI_AZURE_ENDPOINT=https://your-resource.openai.azure.com
export CQLAI_AZURE_DEPLOYMENT=your-deployment-name
endpoint: https://your-resource.openai.azure.com
deployment: gpt-4-deployment
api_version: "2024-02-15-preview"
export CQLAI_AI_PROVIDER=bedrock
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
model: anthropic.claude-3-sonnet-20240229-v1:0
export CQLAI_AI_PROVIDER=vertex
export GOOGLE_CLOUD_PROJECT=your-project
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json
Run AI models locally without cloud dependencies.
curl -fsSL https://ollama.com/install.sh | sh
# Recommended for CQL generation
export CQLAI_AI_PROVIDER=ollama
export CQLAI_OLLAMA_HOST=http://localhost:11434
host: http://localhost:11434
| Model | Parameters | RAM | Best For |
|---|
| llama3 | 8B | 8GB | General use |
| codellama | 7B | 8GB | Code generation |
| mixtral | 8x7B | 48GB | Complex queries |
Use any OpenAI-compatible API endpoint.
provider: openai-compatible
endpoint: https://your-api.example.com/v1
api_key_env: YOUR_API_KEY_VAR
Accuracy: Claude 3 Opus ≈ GPT-4 > GPT-4 Turbo > Claude Sonnet > GPT-3.5
Speed: GPT-3.5 > Claude Haiku > GPT-4 Turbo > Claude Sonnet > GPT-4
Cost: Ollama (free) < GPT-3.5 < Claude Haiku < Sonnet < GPT-4
Privacy: Ollama (local) > Azure (enterprise) > Cloud providers
| Use Case | Recommended Provider |
|---|
| Development | Ollama (free, local) |
| Production (accuracy) | OpenAI GPT-4 or Claude Opus |
| Production (cost) | Claude Haiku or GPT-3.5 |
| Enterprise/Compliance | Azure OpenAI |
| AWS Environment | AWS Bedrock |
| Privacy-critical | Ollama (local) |
# Lower = more deterministic (recommended for CQL)
# Maximum response length
# Include table schemas in context
# Number of schema tables to include
# Always include current keyspace schema
include_current_keyspace: true
# Include table statistics for optimization hints
# Maximum schema size to send
- Never commit API keys - Use environment variables
- Use Azure/Bedrock for enterprise - Better compliance
- Consider Ollama - No data leaves your network
- Rotate keys regularly - Set up key rotation
- Monitor usage - Track API costs and calls
# Store in environment, not config file
export CQLAI_AI_KEY=$(cat ~/.secrets/openai_key)
3. Ensure key is not expired
4. Verify environment variable is set
Error: Rate limit exceeded
1. Use a model with higher limits
2. Add retry configuration
3. Implement request caching
Error: Connection refused
1. Ensure Ollama is running: ollama serve
2. Check port: http://localhost:11434
3. Verify model is pulled: ollama list