Model or dataset
sqlchat/sqlchat avatar
sqlchat/sqlchat

SQL Chat: A Chat-Based SQL Client for Natural Language Database Queries

Chat-based SQL Client and Editor for the next decade

5,844 stars505 forksTypeScriptMIT

At a glance

What is it?
SQL Chat is a Next.js web application that lets you query MySQL, PostgreSQL, MSSQL, TiDB Cloud, and OceanBase using natural language through an OpenAI-backed chat interface. It runs as a hosted service at sqlchat.ai or self-hosted via Docker, and was last pushed on 2026-04-21.
Who is it for?
SQL Chat is a good fit for developers and analysts who want to run ad-hoc database queries using natural language and already have an OpenAI API key. It is not a substitute for a full SQL IDE when you need schema browsing, complex query editors, execution plans, or saved queries.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 163 days ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What SQL Chat Does and Who It Is For

SQL Chat is a chat interface for relational databases. Instead of writing SQL queries directly, you type a question in natural language, and the application uses an OpenAI language model to translate it into SQL, execute it against your connected database, and return the results in the chat thread. The supported databases are MySQL, PostgreSQL, MSSQL, TiDB Cloud, and OceanBase.

The target user is a developer or analyst who already knows what they want from a database but prefers expressing that in plain language over writing SQL syntax. It is also useful for engineers who work with databases infrequently and do not have SQL syntax memorized.

The README positions SQL Chat as a next-generation SQL client for the era of AI-powered developer tools. The practical limitation is that it depends on an OpenAI API key to function; the language model translation is not embedded locally. If the OpenAI API is unavailable or over quota, the chat interface stops working until the issue is resolved.

The live version at sqlchat.ai runs on Vercel with dynamic IP addresses. If you use it to connect to a database, you must add 0.0.0.0 (allow all connections) to your database whitelist, because Vercel does not provide static IPs. Teams with access-controlled databases should consider the self-hosted Docker option instead.

Architecture: Next.js, Prisma, and Two Deployment Modes

SQL Chat is built with Next.js 13, TypeScript, and Prisma for the optional database backend. The frontend uses React 18, Tailwind CSS, and MUI for the component layer.

There are two deployment modes, which the README describes with .env.nodb and .env.usedb environment files. In no-database mode, the application runs without any SQL Chat application database of its own. There is no account system, no per-user quota enforcement, and no payment layer. This is the mode for personal use.

In database mode (NEXT_PUBLIC_USE_DATABASE=true), the application stores account information, usage data, and quota enforcement in a PostgreSQL database. The connection string goes in DATABASE_URL. The README notes that both DATABASE_URL and DATABASE_DIRECT_URL are needed when using Prisma Data Platform; the distinction is for connection pooling.

The Dockerfile uses a multi-stage build: a deps stage installs Node.js dependencies, a builder stage runs the Next.js build, and a runner stage serves the production application. The final image runs as a non-root nextjs user on port 3000.

Self-Hosting with Docker

For personal self-hosted use, run the Docker image with NEXTAUTH_SECRET and OPENAI_API_KEY:

bash
docker run --name sqlchat --platform linux/amd64 --env NEXTAUTH_SECRET="$(openssl rand -hex 5)" --env OPENAI_API_KEY=<<YOUR OPENAI KEY>> -p 3000:3000 --hostname localhost sqlchat/sqlchat

The README notes that NEXTAUTH_SECRET must be set to any arbitrary string; next-auth will complain if it is missing. If you are connecting to a database running on the same host, use host.docker.internal as the database hostname in the connection settings, not localhost, because localhost inside the container refers to the container itself.

For organizations that want to offer a service similar to sqlchat.ai with account management, the .env.usedb configuration adds the database-backed features. The README links to the .env.usedb file in the repository for reference.

To use a self-hosted AI model instead of OpenAI's API, set OPENAI_API_ENDPOINT to the endpoint of an Ollama instance. This routes all model calls through Ollama rather than api.openai.com.

Local Development Setup

Local development uses pnpm. Install dependencies:

bash
pnpm i

Generate the Prisma client:

bash
pnpm prisma generate

Copy the environment file:

bash
cp .env.usedb .env

Add your OpenAI API key to .env. If you want to skip the application database entirely, use .env.nodb instead of .env.usedb.

To set up the application database schema:

bash
pnpm prisma migrate dev

Optionally seed the database with initial data:

bash
pnpm prisma db seed

The dev server starts with pnpm dev or pnpm nodb for no-database mode. The build command is pnpm build, which runs prisma generate and next build in sequence.

Environment Variables and Configuration

The key environment variables that control SQL Chat's behavior:

OPENAI_API_KEY is required. This is the OpenAI API key the application uses for all language model calls. Without it, the chat interface cannot translate natural language to SQL.

OPENAI_API_ENDPOINT defaults to https://api.openai.com. Override this to point to an Ollama instance or another OpenAI-compatible endpoint.

NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY, when set to true, lets users supply their own OpenAI API key through the UI. This is useful for public deployments where the operator does not want to pay for users' API usage.

NEXT_PUBLIC_USE_DATABASE controls whether the account system, quota, and payment features are active. When false (or unset), the application runs in no-database mode.

DATA_BASE_URL and DATABASE_DIRECT_URL hold the PostgreSQL connection strings when database mode is active.

The common error messages documented in the README: "Please sign up to get free quota" means the sqlchat.ai quota for unauthenticated users has been hit, with more detail in the linked issue. "You exceeded your current quota" means the OpenAI API key is over its billing limit. "Failed to request message, please check your network" means the application cannot reach api.openai.com; verify with ping api.openai.com and set OPENAI_API_ENDPOINT if needed.

Limitations and Where SQL Chat Falls Short

SQL Chat is fundamentally an OpenAI API client with a SQL execution layer. It has no offline mode and no local model option built in (though Ollama can provide an OpenAI-compatible endpoint). If OpenAI's API is unreachable or over quota, the chat interface stops working.

The supported database list is MySQL, PostgreSQL, MSSQL, TiDB Cloud, and OceanBase. Oracle, SQLite, MongoDB, and other databases are not in the list. The README notes that more will be added over time, but makes no commitment about which or when.

SQL Chat does not document schema browsing, query history, execution plans, or query export. Traditional SQL clients like DBeaver, which is a widely known open source Java database tool with full schema navigation and a SQL editor, cover this ground directly. DBeaver connects to dozens of databases and provides the kind of detailed schema inspection that SQL Chat does not surface. The two tools serve different needs: SQL Chat is for ad-hoc queries via natural language; DBeaver is for systematic database work with direct SQL control.

The last push to the repository was on 2026-04-21. The MIT license allows unrestricted use and modification.

Editorial conclusion

SQL Chat is a good fit for developers and analysts who want to run ad-hoc database queries using natural language and already have an OpenAI API key. It is not a substitute for a full SQL IDE when you need schema browsing, complex query editors, execution plans, or saved queries. The hosted sqlchat.ai requires whitelisting 0.0.0.0 in your database; teams with security constraints should self-host instead. Check that your database type is in the supported list before evaluating, and decide whether to run in no-database mode (.env.nodb) or full database mode (.env.usedb) with account management.

Frequently asked questions

Does SQL Chat require an OpenAI subscription to use?

SQL Chat requires an OpenAI API key set via the OPENAI_API_KEY environment variable. When NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY is true, users can supply their own key in the UI. Quota is enforced by your OpenAI account; a depleted quota produces the error message documented in the README.

Can SQL Chat run without its own application database?

Yes. The README documents a no-database mode via .env.nodb, which skips the account system, per-user quota enforcement, and payment layer. Database mode uses NEXT_PUBLIC_USE_DATABASE=true and requires a PostgreSQL instance for account and usage data.

Which databases does SQL Chat support?

SQL Chat supports MySQL, PostgreSQL, MSSQL, TiDB Cloud, and OceanBase, as documented in the README. The README notes that more databases will be added over time.

Official sources

  1. Issues
  2. License: MIT
  3. Project website
  4. README
  5. sqlchat/sqlchat on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/sqlchat-sqlchat.svg)](https://hysenlabs.com/projects/sqlchat-sqlchat)