Skip to main content

Generative AI

Kvery integrates OpenAI models so you can write and understand SQL faster. The AI SQL assistant in the editor can draft a query from a plain-language request, explain an existing query, fix an error or suggest optimizations, and Kvery can generate a description for a query — all from inside the editor.

Bring your own key​

The AI features use your own OpenAI API key. You add it once on your profile (see OpenAI key); Kvery then calls OpenAI on your behalf and the usage is billed to your OpenAI account. Without a key, the AI features are unavailable.

Available models​

You pick the model on the OpenAI tab of your profile. Prices are OpenAI's rates in USD per 1 million tokens; repeated parts of a request (such as the database schema in a longer chat) are often billed at the lower cached input rate.

Name in KveryModelInputCached inputOutput
GPT-6 Astra (most capable)gpt-6-astra$10.00$1.00$50.00
GPT-6.1 Sol (recommended)gpt-6.1-sol$2.00$0.10$10.00
GPT-6 Luna (fast, low cost)gpt-6-luna$0.10$0.01$0.50
GPT-5.6 Solgpt-5.6-sol$4.00$0.40$20.00
GPT-5.6 Terragpt-5.6-terra$2.00$0.20$12.00
GPT-5.6 Luna (fast)gpt-5.6-luna$0.20$0.02$1.20
o3 (legacy)o3$2.00$0.50$8.00
GPT-5 mini (legacy)gpt-5-mini$0.25$0.025$2.00
GPT-5 (legacy)gpt-5$1.25$0.125$10.00

Pick the recommended model for everyday work, the fast, low cost one for quick iterations, and the most capable one when a query is genuinely complex. Pricing may change on OpenAI's side. The chat shows the tokens used and the estimated cost of the session.

What the assistant can do​

  • Generate SQL from a natural-language description of what you want. SQL answers can be applied to the editor with one click.
  • Explain an existing query so you understand it before running it.
  • Fix a query that returns an error, and suggest optimizations.
  • Generate a description (a title and a one-sentence explanation) for a query to keep your workspace documented.

The assistant answers either with a complete SQL statement or with a plain-text answer. It uses the current SQL in the editor as context (you can switch this off), and it works in the SQL dialect of the query's connection.

Database schema as context​

To write correct SQL, the assistant gets your database structure (tables, columns and their comments) as context. Smaller schemas are sent completely; larger ones are reduced to the tables relevant to the conversation, up to about 60,000 characters.

How requests are bounded​

To keep requests efficient and predictable, Kvery caps each AI interaction:

  • Up to 8,000 completion tokens per chat response and 2,000 for a generated description. Newer models reason before they answer, and their reasoning tokens count towards the same limit.
  • The conversation history forwarded to OpenAI is limited to 20 user/assistant turn pairs and 50,000 characters in total; longer back-and-forths simply forget the oldest turns.
  • Each user can send up to 30 AI requests per minute (chat, description generation and saving the OpenAI settings together).
  • A request has about 90 seconds to complete; temporary OpenAI errors are retried automatically within that time.

If an answer runs out of its token budget, Kvery tells you so — ask a more specific question or about fewer tables.

Tips​

  • Give the assistant context — table and column names, what you're trying to achieve — for better SQL.
  • Always review generated SQL before running it, especially write statements.
  • Use drafts to test AI-generated changes safely before publishing.
  • Clear the chat when you switch topics: a shorter history is faster and cheaper.