Getting Started
Learn how to create your first Text2SQL instance and generate SQL from natural language.Quick Example
Here’s a complete example using PostgreSQL:Step-by-Step Setup
1. Import Dependencies
2. Create Database Adapter
The adapter handles database introspection and query execution.SQLite Example
PostgreSQL Example
3. Configure Context Store
The context store manages conversation history and schema cache.4. Create Text2SQL Instance
5. Generate SQL
Use thetoSql() method to convert natural language to SQL:
6. Execute and Get Results
You can execute the generated SQL directly:Configuration Options
Text2SQL Constructor
Adapter Options
All adapters support:Grounding Functions
Grounding functions control what schema metadata the AI receives:Schema Introspection
The first time you calltoSql() or chat(), Text2SQL introspects your database schema. This is cached automatically:
Error Handling
Complete Example
Here’s a complete working example with SQLite:app.ts
Next Steps
Database Adapters
Learn about database-specific features
Teachables
Inject domain knowledge to improve accuracy
Conversational
Build multi-turn conversations
API Reference
Explore the full API