AI-powered REPL console for Prisma ORM with natural language query generation
- From your project directory, run:
npx prisma-ai-console- Optional flags:
--clientor-c: Set Prisma client path (default:./node_modules/@prisma/client)--schemaor-s: Set schema file location for AI features (default:./prisma/schema.prisma)
npx prisma-ai-console -c ./node_modules/@prisma/client -s ./prisma/schema.prismaGenerate Prisma queries using natural language! The console now includes an ai() function that understands your database schema and generates the appropriate Prisma commands.
Set your API key as an environment variable:
# For OpenAI
export OPENAI_API_KEY=your-api-key-here
# Or for Anthropic Claude
export ANTHROPIC_API_KEY=your-api-key-here
# Or for OpenRouter (supports multiple models)
export OPENROUTER_API_KEY=your-api-key-here
export OPENROUTER_MODEL=anthropic/claude-3.5-sonnet # Optional, defaults to claude-3.5-sonnetIf multiple keys exist, OpenRouter will be used first, then OpenAI, then Anthropic.
// 1. ai(query) - Generate a Prisma command
await ai('find all users with gmail addresses')
// Displays the command, copy and paste to execute
// 2. run(query) - Generate and execute in one step
await run('get the top 10 most played songs with their artist names')
// Generates the command and runs it immediately, returns the result◭ > await ai('find all users created in the last 7 days')
🤖 Generating Prisma command...
✨ Generated command:
await prisma.user.findMany({ where: { createdAt: { gte: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000) } } })
💡 Copy and paste to execute, or assign to a variableTwo powerful commands:
ai(query)- Generate Prisma commands from natural languagerun(query)- Generate and execute in one step
The AI automatically:
- Reads your Prisma schema
- Understands your database structure
- Generates accurate Prisma Client queries
- Supports complex queries with relations, filters, and aggregations
This project is built on top of prisma-console by Kinjal Raykarmakar. All the original REPL console features are still available, with AI-powered query generation added on top.
Original console feature included:



