Decisions API picks the tables. AI2SQL writes the SQL.
LIVE DEMO · POWERED BY OPENAI DECISIONS API
Ask a question or pick an example. The ranking appears on the left, the SQL and real rows here.
SQL from the top 4 tables
Result on demo_shop
Schema sent to the SQL model
How it works
Ask a question about a 56-table schema. One call ranks every table, the SQL is written from the top 4, and it runs on a real sample database.
Decisions API ranks every table
One call. Each of the 56 tables is an option with its column names, and every table gets a probability.
AI2SQL writes the SQL
The SQL model sees only the top 4 tables, not all 56. A smaller prompt with fewer wrong tables to choose from.
It runs on a real database
The query runs read-only on demo_shop, a PostgreSQL sample with fake customers, orders and products.
Try it on your own database
Connect PostgreSQL, MySQL or SQL Server and ask questions in plain English.
Try it on your own database →Free plan: 3 queries a day on a demo database. Every paid plan starts with a 7-day trial; a credit card is required.
Questions
What does this demo show?
Table selection before text-to-SQL. The OpenAI Decisions API ranks all 56 tables of a sample schema for your question in a single call, AI2SQL writes PostgreSQL from the 4 highest-ranked tables only, and the query runs on a real sample database.
What is sent to OpenAI?
Your question and the table and column names of the sample schema, to rank the tables. Then your question and the 4 chosen tables' definitions, to write the SQL. No row data is sent.
Why the top 4 and not a probability cut-off?
The probabilities are very concentrated: the first table often gets almost all of it and the rest round to zero, even when the query needs three tables. A fixed number of tables keeps every table the query needs; a threshold would drop them.
Why do some questions say they couldn't run?
Only 4 of the 56 tables exist in the sample database: customers, orders, order_items and products. The other 52 are realistic extra tables that make the ranking harder. A question about warehouses or support tickets gets SQL for those tables, but there is no data behind them.
Can I try it on my own database?
Yes. Sign up for AI2SQL and connect your database. The Free plan includes 3 queries a day on a demo database. Every paid plan starts with a 7-day trial, and a credit card is required to start it.
AI2SQL uses the OpenAI Decisions API through OpenAI's public API. Background on table selection: ai2sql.io/jev