.           .
    /' \         / \
   /   | .---.  |   \
  |    |/  _  \|    |
  |    |\  _  /|    |
   \   | '---'  |   /
    \./         \./
      |   .---.   |
      |  /  _  \  |
      | |  (_)  | |
      |  \  _  /  |
      |   '---'   |
OPENAI / ANTHROPIC / GOOGLE / GROQ

ASK QUESTIONS.
GET SQL.

AI-powered natural language to SQL that learns your business. Schema-aware generation with teachable domain knowledge. Multi-database support.

$ npm install @deepagents/text2sql

CAPABILITIES

Module Active

Schema-Aware Generation

Automatic introspection of tables, relationships, indexes, and constraints for accurate query generation.

grounding: [tables(), indexes()]
Module Active

Teachable Knowledge

Encode domain expertise with 17 teachable types: terms, hints, guardrails, examples, glossaries, and more.

term("MRR", "Monthly Recurring Revenue")
Module Active

Multi-Database Support

PostgreSQL, SQLite, and SQL Server adapters with database-specific optimizations.

import { Postgres } from "@deepagents/text2sql/postgres"

INTERACTIVE PLAYGROUND

Experience natural language to SQL generation. Ask questions in plain English and see the generated queries.

SQL_MODE
READY

TRY: "show me top customers by revenue"

QUICK START

Get up and running in minutes with a simple setup.

quick-start.tsTypeScript
import { Text2Sql, InMemoryHistory } from '@deepagents/text2sql';
import { Postgres, tables, indexes, constraints } from '@deepagents/text2sql/postgres';

const text2sql = new Text2Sql({
  version: 'v1',
  adapter: new Postgres({
    execute: async (sql) => pool.query(sql).then(r => r.rows),
    grounding: [tables(), indexes(), constraints()],
  }),
  history: new InMemoryHistory(),
});

// Generate SQL from natural language
const sql = await text2sql.toSql(
  "Show me the top 10 customers by revenue"
);