AI Query Assistant

The AI Query Assistant lets you generate SQL queries from natural language questions. Simply describe what you want to know about your data, and the assistant writes the SQL for you — taking the current database schema into account.

The assistant is integrated into the SQL Console of the Data Browser. Open the SQL Console (Ctrl+Enter from any table window, or via the menu) and look for the "AI Assistant" button in the toolbar.


Conversation Mode

The AI Assistant works as an interactive dialog: you type a question in natural language, the assistant generates the SQL, and you can follow up with further questions or refinements — all within the same dialog window. Each exchange is kept as context so the assistant understands follow-up questions that refer to previous ones.

You can refine a query iteratively:

“Show all orders placed in the last 30 days.”
SELECT * FROM orders WHERE order_date >= CURRENT_DATE - 30

“Now group them by customer.”
SELECT customer_id, COUNT(*) FROM orders WHERE order_date >= CURRENT_DATE - 30 GROUP BY customer_id


Silent Mode

Silent mode is a deep integration of the AI assistant into the SQL Console workflow. Every SQL statement generated by the AI is prefixed with a comment that records the original natural language question:

/* AI:
   Show all orders placed in the last 30 days
 */
SELECT * FROM orders WHERE order_date >= CURRENT_DATE - 30

When the cursor is inside such a statement, the AI Assistant (Silent) action becomes available. It re-generates the SQL directly in the editor — without opening the dialog — and executes it immediately. A typical use is to edit the /* AI: ... */ comment to refine or extend the question and then let the AI update the query in place.

Trigger silent mode via:

  • Right-click context menu → AI Assistant (Silent)
  • Keyboard shortcut Ctrl+Shift+S

The menu item is only enabled when the current statement carries an /* AI: ... */ header.


Supported AI Providers

The assistant works with any of the following AI backends:

Anthropic Claude models via the Anthropic API. Requires an API key from console.anthropic.com. Default model: claude-haiku-4-5-20251001.
OpenAI-compatible OpenAI and any API that follows the OpenAI chat-completions format (Azure OpenAI, Groq, etc.). Requires an API key. Default model: gpt-4o-mini.
OpenRouter Access hundreds of models through a single endpoint at openrouter.ai. Free models are available without payment. Default model: google/gemma-3-27b-it. → Setup guide
Ollama Run models locally on your own machine — no API key required and no data leaves your system. Requires a running Ollama instance. Default model: llama3.2.

Configuration

The AI provider settings are shown at the bottom of the AI Assistant dialog. Open the dialog via Edit → AI Assistant, or via the AI Assistant button in the SQL Console toolbar. Configure:

  • Provider — select Anthropic, OpenAI-compatible, OpenRouter, or Ollama.
  • API URL — pre-filled with the provider default; change only for custom endpoints (e.g. Azure, a local proxy, or a self-hosted OpenRouter mirror).
  • API Key — your secret key for the chosen provider. Not required for Ollama.
  • Model — the model name to use. Refer to your provider’s documentation for available model identifiers.
  • Max Tokens — the maximum number of tokens in the generated response (default: 8192).

Smart Table Selection

For databases with many tables, sending the full schema to the AI in every request can be slow and expensive. The Smart Table Selection mode (checkbox "Relevant tables only") solves this with a two-step approach:

  1. A lightweight first pass sends only the list of table names to the AI, which returns the subset of tables relevant to the question.
  2. Only the schema of those selected tables is included in the main request that generates the SQL.

Smart Table Selection activates automatically when the schema exceeds a threshold number of tables. It can also be enabled or disabled explicitly in the settings.


Custom System Prompt

The system prompt lets you set standing instructions that are sent to the AI before every conversation. Click the System Prompt… button at the bottom of the AI Assistant dialog to edit it.

It is a good place to establish general rules for SQL generation, for example:

  • Aliases for complex expressions — instruct the AI to always assign a meaningful column alias to calculated fields, e.g. SUM(amount) AS total_amount instead of an unnamed expression.
  • Preferred SQL dialect or syntax conventions for your database.
  • Formatting rules such as uppercase keywords or a specific indentation style.
  • Database-specific constraints or naming conventions the AI should respect.