AI Assistant
An optional assistant that uses your own AI service and API key. It is off until you configure it.
#34.1Opening it
Ctrl+Shift+A, the 🤖 toolbar button, or Session → Show AI panel. It is available on the SQL Editor and Debugger modules and slides in from the right; drag its edge to resize (220–480 px). Its visibility and width are remembered.
#34.2Configuration (bring your own key)
Configuration lives in one place only: Settings → AI Configuration. Until it is filled in, the panel shows "AI is not configured" with a button that takes you straight there; the ⚙ in the panel header opens the same section.
There is no provider list to choose from. DBCraft speaks the OpenAI-compatible API, so any endpoint that speaks it will work — a commercial service, a gateway, or a model server running on your own machine.
| Field | Notes |
|---|---|
| API Key | Your key. A show/hide toggle reveals it. Optional for a local server on localhost. |
| Base URL | The endpoint, for example https://api.openai.com/v1. A suggestion list is attached, but you may type any URL. A pasted …/chat/completions path or a trailing slash is trimmed for you. |
| Model | Populated automatically by Test Connection, and disabled until then. |
Test Connection validates the Base URL, checks the key, calls GET {Base URL}/models, fills the Model dropdown with what came back, and records the detected service name. The Status line then reads one of:
- ✓ Connected — Provider: Google Gemini · Models: 12 discovered.
- ❌ Connection failed — with the reason, for example 401 Unauthorized — the API key was rejected, or Invalid Base URL.
If the endpoint does not offer model listing, the status still reports Connected and the panel says "Unable to retrieve models automatically. You can enter a model ID manually." — the Model field switches to free text. Enter a model ID manually / Choose from discovered models toggles between the two at any time.
The detected service name — OpenAI, Google Gemini, Groq, OpenRouter, LM Studio, Ollama, or Unknown OpenAI-Compatible API — is informational only. It is derived from the Base URL, the response headers and the returned model list, and it never changes how a request is made.
Save stores the API key, Base URL, selected model and detected name on this machine. Clear AI configuration and disable AI removes them.
Base URLs that are known to work:
https://api.openai.com/v1
https://generativelanguage.googleapis.com/v1beta/openai
https://openrouter.ai/api/v1
https://api.groq.com/openai/v1
https://api.together.xyz/v1
http://localhost:11434/v1 (Ollama)
http://localhost:1234/v1 (LM Studio)🔒 Where your key goes. The key is stored locally on this device so you do not have to retype it, and is sent only to the Base URL you entered. It never reaches DBCraft’s servers — there are none.
#34.3What the assistant can and cannot do
The AI is strictly assistive. It returns text. That is the whole of it.
It has no ability to:
- execute SQL, or send anything at all to your database;
- run scripts;
- create, alter or drop objects;
- commit, roll back, or open a transaction;
- disconnect a database or modify a saved connection;
- change any application setting;
- read local files.
This is not a rule the model is asked to respect — it is the shape of the integration. The assistant is given no tools and no callback into the application, so a reply reaches nothing but the chat bubble it is drawn into. The only action available on a reply is Insert into Editor, which appends the snippet to your active editor tab and stops there. Running it is a separate, deliberate step you take yourself, with the usual F8.
When a suggestion contains DDL or DML, the reply is flagged: "This snippet changes data or structure. Review it before you run it."
These guarantees are enforced by DBCraft, not by the endpoint you configured, so they hold identically for every service and every model.
#What is sent
Each request carries the minimum needed:
- your prompt;
- the editor context — the SQL you last executed, or the object you selected in the browser. A chip above the input box shows when context is attached, with a Remove link that detaches it. Long context is truncated.
DBCraft never sends database passwords, connection strings, credentials, API keys, private keys, secret values or local configuration files. Your API key travels in the request’s authorisation header, never in the prompt. As a safety net, any secret that appears in the SQL itself — an IDENTIFIED BY clause, a pasted connection string, a key — is replaced with [redacted] before the request leaves your machine.
#Schema accuracy
The assistant sees only the context above, not your whole catalogue. It is instructed not to invent tables, columns or packages: if you ask about an object it has not been shown, it should tell you it could not verify that the object exists and mark any placeholder names, rather than guessing at a schema.
What leaves your machine. Your prompt and the attached SQL do travel to the endpoint you configured. Do not use the assistant against systems whose SQL or schema names you may not disclose to a third party. The rest of the product works fully with AI switched off.
#34.4Using the assistant
Pick an action — these shape the request:
| Action | Purpose |
|---|---|
| Generate | Write SQL/PL/SQL from a description. |
| Explain | Explain what code does. |
| Optimize | Suggest performance improvements. |
| Fix | Fix errors and issues. |
| Review | Code review and best practices. |
Type in the box and press Enter to send (Shift+Enter for a new line). Three quick prompts are offered as one-click starting points.
Assistant replies render as formatted text with code blocks. Each reply carries:
- Copy — copies the whole reply.
- Insert into Editor — appears when the reply contains a code block; appends that code to the active SQL editor tab. It is not executed (§34.3).
#34.5AI elsewhere in the product
The same configuration — and the same limits as §34.3 — powers two other features:
Both send only the statement and the analysis already on screen, and both report clearly when AI is not configured.