Skip to main content

AI Chat

TablePro has a built-in AI chat panel for writing, explaining, and fixing SQL queries. It supports Claude (Anthropic), OpenAI, Gemini (Google), OpenRouter, Ollama, and custom OpenAI-compatible endpoints.

Opening the AI Chat Panel

Press Cmd+Shift+L, click the AI button in the toolbar, or go View > Toggle AI Chat. The panel appears on the right side of the editor.
AI chat panel

Chatting with AI

Type your question and press Enter. The AI receives your database type, schema (tables, columns, foreign keys), and current query, then responds with context-aware suggestions in Markdown with syntax-highlighted SQL code blocks. SQL code blocks in responses have Copy and Insert to Editor buttons. Token counts appear below each response for tracking API usage.
AI response with code block actions
Token usage display
Conversations save automatically to disk and auto-title from your first message. Use the chat panel buttons to browse history, start a new conversation, or delete one.
Conversation history
Failed responses show a Retry button; successful ones have a Regenerate button to get a new answer. Responses stream in real-time. Click Stop to cancel. You can scroll up while typing a new message.
Streaming response

Configuring AI Providers

TablePro supports Claude, OpenAI, Gemini, OpenRouter, Ollama, and custom OpenAI-compatible endpoints. Ollama auto-detects on launch. Configure providers in Settings (Cmd+,) > AI:

Adding a Provider

Click Add Provider, choose a type, enter your API key (endpoint pre-fills), specify a model or click Fetch to pull available models, then click Test to verify.
AI settings - provider configuration

API Key Security

API keys are stored in your macOS Keychain. They never touch plain text files or preferences.

Feature Routing

Route Chat, Explain Query, Optimize Query, Fix Error, and Inline Suggestions to different providers, or use the default (first enabled provider).
Feature routing configuration
Configure what the AI receives in Settings > AI > Context: database schema (on), current query (on), query results (off), and max tables (20). More context improves answers but increases data sent. Set a per-connection AI policy (Use Default, Always Allow, Ask Each Time, or Never) to control access on sensitive connections.
Per-connection AI policy

Editor Integration

Context Menu

Right-click SQL in the editor for Explain with AI and Optimize with AI options.
SQL editor context menu with AI items
Toggle AI Chat (Cmd+Shift+L), Explain (Cmd+L), or Optimize (Cmd+Option+L). All customizable in Settings > Keyboard > AI.

Ask AI to Fix Errors

Query error dialogs have an Ask AI to Fix button that opens the chat panel, sends the failed query and error message, and gets AI suggestions.
Query error dialog with Ask AI to Fix button