Documentation/Features/AI assistant

AI SQL assistant

Preview

An assistant inside Query Studio that writes, explains and tunes SQL using your schema as context. You bring the model: pick a provider for your organisation and use your own API key.

Not generally available yet

The assistant panel and the provider integrations are in the product, but setting up a provider and key is not yet exposed in the admin settings. Until it is, the assistant reports that no provider is configured. This page describes how it works so you can plan for it.

What it does

Generate

Describe what you want in plain English and get SQL written against the selected data source's real tables and columns.

POST /api/v1/queries/ai/generate

Explain

Paste a query and get a plain-English walkthrough of what it does and what it returns.

POST /api/v1/queries/ai/explain

Optimize

Get a rewritten query and performance suggestions for the database you are running it on.

POST /api/v1/queries/ai/optimize

Providers

ProviderHow it runs
AnthropicClaude models, with your Anthropic API key
OpenAIGPT models, with your OpenAI API key
Google GeminiGemini models, with your Google AI key
xAI GrokGrok, with your xAI API key
OllamaLocal models on your own hardware, so prompts never leave your network

Your key, encrypted

One active provider per organisation. API keys are encrypted with AES-256-GCM under a purpose-specific key, so a stored AI key can never be opened as a data source credential or the other way round.

Your bill, your model

Requests go straight from your DBCraft server to the provider you chose, on your account. Use Ollama if nothing may leave your network.

What is sent to the provider

  • The schema of the selected data source (table names, column names and types) and the database type.
  • Your request: the plain-English prompt for Generate, or the SQL for Explain and Optimize.
  • Before SQL is sent for Explain or Optimize, its literal values are stripped. The model gets the shape of the statement, not the account numbers or emails it was run with.
  • No query results or table rows are sent.

The assistant only works on data sources you are allowed to query, and every request is logged for audit.

Using Claude already?

The MCP server is available today and lets Claude explore schemas, run read-only queries and build whole dashboards against your DBCraft instance.