AI SQL Generation
Logchef can translate natural language questions into ClickHouse SQL queries using OpenAI-compatible LLMs. The AI is schema-aware — it knows your table’s columns and types.
- Open any log source
- Click the AI assistant button (wand icon) in the query editor
- Describe what you want in plain English
- Review the generated SQL, then insert it into the editor
If you already have a query in the editor, the AI uses it as context for refinements.
Example Queries
Section titled “Example Queries”"Show error logs from the last 6 hours""Count logs by severity for today""Find logs containing 'connection refused' from the payments service""Top 10 most frequent error messages this week""Logs where trace_id = 'abc123'"Configuration
Section titled “Configuration”Configure via Administration → System Settings → AI:
| Setting | Description | Default |
|---|---|---|
| Enabled | Toggle AI features | true |
| API Key | Your OpenAI API key | — |
| Base URL | API endpoint | https://api.openai.com/v1 |
| Model | Model name | gpt-4o |
| Max Tokens | Max tokens to generate | 1024 |
| Temperature | Randomness (0.0–1.0) | 0.1 |
Supported Providers
Section titled “Supported Providers”Any OpenAI-compatible API works:
| Provider | Base URL |
|---|---|
| OpenAI | https://api.openai.com/v1 (default) |
| OpenRouter | https://openrouter.ai/api/v1 |
| Azure OpenAI | Your Azure endpoint |
| Local models | Your local server URL |
Environment Variables
Section titled “Environment Variables”For containerized deployments, seed the initial config via env vars:
export LOGCHEF_AI__ENABLED=trueexport LOGCHEF_AI__API_KEY="sk-your-key"export LOGCHEF_AI__MODEL="gpt-4o"After first boot, the Admin UI takes precedence over env vars.
MCP Integration
Section titled “MCP Integration”For AI assistant integration outside the web UI (e.g., Claude Desktop), see MCP Server.
Limitations
Section titled “Limitations”AI-generated SQL should always be reviewed before execution. The model can produce incorrect queries, especially for complex aggregations or unfamiliar schemas. Start simple and iterate.