Skip to main content

Installation

Install the Text2SQL package and your database-specific adapter.

Requirements

  • Node.js - LTS version (20+)
  • TypeScript - 5.0+ (recommended)
  • Database client - Depends on your database (see below)

Core Package

Install the main Text2SQL package:
npm install @deepagents/text2sql
This includes:
  • Core Text2SQL engine
  • Context management system
  • All database adapters (SQLite, PostgreSQL, SQL Server, MySQL, BigQuery)
  • Synthesis tools for training data generation

Database-Specific Setup

Depending on your database, you’ll need additional peer dependencies.

PostgreSQL

Install the pg client:
npm install pg
npm install -D @types/pg
Import from the PostgreSQL adapter:
import { Postgres, tables, views, info } from '@deepagents/text2sql/postgres';

SQLite

SQLite requires no additional dependencies. Use Node.js native sqlite3 or better-sqlite3:
npm install better-sqlite3
npm install -D @types/better-sqlite3
Import from the SQLite adapter:
import { Sqlite, tables, views, info } from '@deepagents/text2sql/sqlite';

SQL Server

Install the mssql client:
npm install mssql
Import from the SQL Server adapter:
import { SqlServer, tables, views, info } from '@deepagents/text2sql/sqlserver';

MySQL / MariaDB

Install the mysql2 client:
npm install mysql2
Import from the MySQL adapter:
import { Mysql, Mariadb, tables, views } from '@deepagents/text2sql/mysql';

BigQuery

BigQuery support is included in the package:
# No additional installation needed
Import from the BigQuery adapter:
import { BigQuery, tables, views, info } from '@deepagents/text2sql/bigquery';

AI Model Provider

Text2SQL works with any model provider supported by the Vercel AI SDK. Install your preferred provider:

OpenAI

npm install @ai-sdk/openai
import { openai } from '@ai-sdk/openai';

const text2sql = new Text2Sql({
  model: openai('gpt-4o'),
  // ...
});

Anthropic

npm install @ai-sdk/anthropic
import { anthropic } from '@ai-sdk/anthropic';

const text2sql = new Text2Sql({
  model: anthropic('claude-3-5-sonnet-20241022'),
  // ...
});

Groq

npm install @ai-sdk/groq
import { groq } from '@ai-sdk/groq';

const text2sql = new Text2Sql({
  model: groq('llama-3.3-70b-versatile'),
  // ...
});

Google Generative AI

npm install @ai-sdk/google
import { google } from '@ai-sdk/google';

const text2sql = new Text2Sql({
  model: google('gemini-2.0-flash-exp'),
  // ...
});

Context Store

Install the context management package:
npm install @deepagents/context
This provides:
  • Context engine for schema and conversation management
  • Fragment types (term, hint, guardrail, etc.)
  • Storage adapters (in-memory, SQLite)
import { InMemoryContextStore, SqliteContextStore } from '@deepagents/context';

// In-memory (for development)
const store = new InMemoryContextStore();

// SQLite (for production)
const store = new SqliteContextStore({ path: './context.db' });

Verify Installation

Create a simple test file to verify everything is installed correctly:
test.ts
import { Sqlite, tables } from '@deepagents/text2sql/sqlite';
import { Text2Sql } from '@deepagents/text2sql';
import { openai } from '@ai-sdk/openai';
import Database from 'better-sqlite3';

const db = new Database(':memory:');

const adapter = new Sqlite({
  execute: (sql) => db.prepare(sql).all(),
  grounding: [tables()]
});

console.log('Text2SQL installed successfully!');
Run it:
node test.ts

Next Steps

Getting Started

Write your first natural language query

Database Adapters

Configure your database adapter

Build docs developers (and LLMs) love