Cyber-MySQL-OpenAI is a Node.js library that translates natural language questions into SQL, executes them against MySQL databases, and returns results with human-readable explanations. Version 0.3.3 provides features such as self-correcting error handling (up to 3 reflection attempts), structured output via OpenAI function calling, business context awareness, foreign key relationship detection, confidence scoring, multi-language support (English and Spanish), in-memory caching, token optimization, and query validation. It is actively maintained with frequent updates and full TypeScript support.
npm install cyber-mysql-openaiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates initializing a Translator with MySQL and OpenAI configs, then querying for user registrations.
Wrap your config as { mysql: {...}, openai: {...} }Specify a compatible model in translator config: { openai: { model: 'gpt-4' } }Implement external caching (e.g., Redis) if persistence is needed.
Run: npm install cyber-mysql-openai
Use: import { Translator } from 'cyber-mysql-openai'Set process.env.OPENAI_API_KEY to a valid key.
Check MYSQL_USER and MYSQL_PASSWORD, and ensure the user has access to the database.