A command-line tool that converts natural language queries into SQL. It analyzes Sequelize models to understand your database schema and generates accurate queries from plain English input.
- AI-Powered: Uses Qwen 3 for intelligent SQL generation
- Schema-Aware: Parses Sequelize models to extract table structures and relationships
- Interactive Chat: Command-line interface with conversation history
- Multi-Command: Built-in commands for schema inspection, model details, and more
Install globally via NPM:
npm install -g nl2sql-cli- Get an OpenRouter API key from openrouter.ai/keys
- Set your API key:
Or create a
export OPENROUTER_API_KEY='your-key-here'
.envfile withOPENROUTER_API_KEY=your-key-here
Navigate to a project with Sequelize models and run:
nl2sql chat/help- Show commands/schema- Display schema/models- List models/explain <query>- Explain similarity scores (e.g., /explain show users)/history- View history/clear- Clear chat/model <name>- Switch AI model/exit- Quit
The CLI uses semantic search to find relevant tables. Help it work better by:
- Add comments to your models:
// User accounts and authentication data
const User = sequelize.define('User', { ... });-
Use descriptive column names:
- ✅
email,phone_number,created_at - ❌
col1,data,field_x
- ✅
-
Document relationships clearly:
User.hasMany(Order, { as: 'purchases', foreignKey: 'customer_id' });No special configuration needed - the system learns from your schema structure!
- Show all users
- Find users created recently
- Get top products by sales
- List orders with customer details
- Count active users
- Requires Node.js 18+
- Run
npm run devfor development - Use
npm run formatto format code with Prettier - Build with
npm run build
- Analyzes Sequelize models in
models/directory - Extracts schema (tables, columns, associations)
- Sends natural language + schema to Qwen 3
- Returns executable SQL queries
Open an issue on GitHub for questions or problems.