Core API Reference
Complete API documentation for the Text2SQL core classes.Text2Sql Class
The main class for natural language to SQL conversion.Constructor
Text2SqlConfig
TeachingsOptions
Methods
toSql()
Generate SQL from natural language:input- Natural language question
- Promise resolving to SQL query string
chat()
Start or continue a conversational session:messages- Array of chat messagesoptions- Optional chat configuration
- Promise resolving to
UIMessageStream
index()
Manually trigger database introspection:- Promise resolving to array of context fragments
toPairs()
Generate training data pairs using a producer factory:factory- Function that creates a pair producer
- Promise resolving to array of question-SQL pairs
Adapter Abstract Class
Base class for all database adapters.Abstract Properties
Abstract Methods
execute()
validate()
runQuery()
quoteIdentifier()
escape()
buildSampleRowsQuery()
Concrete Methods
introspect()
format()
toNumber()
parseTableName()
escapeString()
Types
Table
Column
ColumnStats
Relationship
ExtractedPair
Utility Functions
toTeachings()
Auto-generate teachables from schema:input.schema- Schema as string (JSON or text)input.context- Optional additional contextoptions.model- Optional AI model (default: groq)
- Promise resolving to teachable fragments
Next Steps
Teachables API
Teachable fragment types
Adapters API
Adapter interface details