Model or dataset
sqlchat/sqlchat avatar
sqlchat/sqlchat

SQL Chat turns SQL into a chat box, and one flag decides if it has accounts

Chat-based SQL Client and Editor for the next decade

5,856 stars505 forksTypeScriptMIT

At a glance

What is it?
A Next.js chat front end for MySQL, PostgreSQL, MSSQL, TiDB Cloud and OceanBase where NEXT_PUBLIC_USE_DATABASE is the switch between a private tool and a service with accounts, quotas and payments.
Who is it for?
SQL Chat fits a single operator who wants to query a database by asking for it, and it fits that operator precisely in its no-database mode, where the only two variables that matter are NEXTAUTH_SECRET and OPENAI_API_KEY. Before turning NEXT_PUBLIC_USE_DATABASE on, work out who pays for the model calls, because usage collection, per-user quotas and payment all switch on with it and a Prisma migration has to have run.
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 25 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 November 15, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • sqlchat/sqlchat5,856 ★ · +10
Star history
Repository2026-09-142026-11-15
sqlchat/sqlchat5.8k5.9k

10 Stars in the last 62 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

One boolean switches accounts, quotas and payments on

The same codebase serves two very different products, and a single environment variable picks which one you get. Set NEXT_PUBLIC_USE_DATABASE to true and the project starts with an account system, per-user quota enforcement, payment, and usage data collection. Leave it false and you have a chat box pointed at a database with nobody to log in. The two setups ship as two example files, .env.nodb and .env.usedb. The instruction is blunt about which to reach for: run without a database if you just want it for yourself, run with one if you want to offer a service like sqlchat.ai, where the database stores account and usage information. Two other switches sit next to it. NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY set to true lets users bring their own OpenAI key rather than spend yours, and OPENAI_API_ENDPOINT decides which model endpoint the chat talks to.

The published docker run pins linux/amd64 and a five byte secret

Running it yourself needs exactly two variables, and the command that does it is published in full:

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 NEXTAUTH_SECRET value is generated inline from openssl, and the note under it says the content does not matter, only that something is there: pass an arbitrary string or next-auth will complain. The platform flag pins the image to linux/amd64, so on an Apple Silicon machine the container runs under emulation rather than natively. One more detail is easy to lose: when the database you want to talk to sits on the same machine, the host you type into the connection settings has to be host.docker.internal, not localhost, because inside the container localhost is the container.

OPENAI_API_ENDPOINT is the only documented exit from OpenAI

Three settings control the model side. OPENAI_API_KEY is the OpenAI API key itself. OPENAI_API_ENDPOINT defaults to https://api.openai.com, and the documented way to replace it is to stand up a self-hosted model with Ollama and point the endpoint at that instead, which turns the dependency on a hosted API into a local one. The third, NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY, decides whether the key field is available to the person using the app: set it to true and users bring their own OpenAI key, leave it unset and the operator's key pays for every conversation. Two failure messages map onto this layer. An exceeded quota message means the OpenAI key has run out of quota and the OpenAI account has to be checked, while a failed request message means the endpoint was unreachable; the diagnostic offered for that is a single ping, and the alternative is setting OPENAI_API_ENDPOINT in the interface or in the environment.

Whitelisting every address is what the hosted service asks of your database

The hosted version at sqlchat.ai runs on Vercel, and Vercel uses dynamic IP addresses, so a database that only accepts known addresses cannot tell where the query came from. The consequence is stated without hedging: to connect to your database through sqlchat.ai you have to add 0.0.0.0, which allows all connections, to the database whitelist IP. Any host firewall or security group that carries that entry becomes decorative, and any table the account can reach becomes reachable from the internet. The project's own answer to that concern is the self-host route described above, and the hosted route points at a separate privacy policy page for how data is handled. Nothing in the project describes a narrower option, such as a fixed outbound address or a tunnel, so the choice is between a hosted front end with an open whitelist and your own container.

Prisma wants a second connection string, and both point at the same database

Database setup is the part with the most moving pieces, and the section on it can be skipped outright with NEXT_PUBLIC_USE_DATABASE=false if you are not building anything that needs a database. Otherwise you start a Postgres instance, create the schema, and connect:

sql
CREATE DATABASE sqlchat;

The connection string goes into DATABASE_URL, for example postgresql://postgres:YOUR_PASSWORD@localhost:5432/sqlchat?schema=sqlchat, and a second variable, DATABASE_DIRECT_URL, has to be set as well, with a link to an article explaining why Prisma wants two. Then the schema and the optional seed data:

bash
pnpm prisma migrate dev
bash
pnpm prisma db seed

On macOS the Postgres step names three apps that will start a local server: Stackbricks, DBngin and Postgres.app. The dev path is short, since the repository ships pnpm scripts, and nodb and usedb are two of them, each wrapping the dev server with env-cmd against one of the two example files.

The image installs its dependencies with pnpm and builds them with yarn

The Dockerfile starts from node:18-alpine and splits into a deps stage, a builder and a runner. The deps stage adds libc6-compat, openssl and openssl-dev, copies package.json and pnpm-lock.yaml, then runs yarn global add pnpm followed by pnpm i --frozen-lockfile. The builder copies node_modules across, copies the tree in, and builds with yarn run build. The mismatch is real and harmless in that spot, because the build script is prisma generate && next build with no package manager inside it, but the two tools are both present in the same image. The runner installs openssl again, with a comment that Prisma needs it in production, creates a nextjs user at uid 1001 and a nodejs group at gid 1001, and copies three things: public, the standalone output directory, and .next/static. It finishes as USER nextjs, EXPOSE 3000, PORT 3000, and CMD ["node", "server.js"].

Five database names, three error strings, and no tagged release

The supported list is short and specific: MySQL, PostgreSQL, MSSQL, TiDB Cloud and OceanBase, with the promise to add more over time, all reached through a chat that handles queries and modifications, additions and deletions. The project publishes no releases, so there is no tagged version to pin and nothing to diff against when something changes; the last push to the default branch main is dated 2026-10-21. The common errors are given as three literal strings you may search for later: please sign up to get free quota, which points at issue 141, you exceeded your current quota, which is an exhausted OpenAI key, and failed to request message, which is a network problem reaching the endpoint. Beyond that, the project does not document how a generated deletion is confirmed before it runs, what a long query times out at, or how a conversation is exported, so those three answers have to come from reading the source in src/ and prisma/.

Editorial conclusion

SQL Chat fits a single operator who wants to query a database by asking for it, and it fits that operator precisely in its no-database mode, where the only two variables that matter are NEXTAUTH_SECRET and OPENAI_API_KEY. Before turning NEXT_PUBLIC_USE_DATABASE on, work out who pays for the model calls, because usage collection, per-user quotas and payment all switch on with it and a Prisma migration has to have run. If you connect to the hosted sqlchat.ai instead of self-hosting, the database whitelist has to accept connections from anywhere, which is a decision to make deliberately.

Frequently asked questions

Which AI is better for SQL work in SQL Chat?

SQL Chat does not compare models. The only model choice it documents is the endpoint: OPENAI_API_ENDPOINT defaults to https://api.openai.com, and the documented way to change it is to run a self-hosted model with Ollama and point the endpoint there.

What does SQL Chat do with a natural language question?

It is a chat-based SQL client that uses natural language to communicate with the database, implementing operations such as query, modification, addition and deletion. It is built with Next.js and supports MySQL, PostgreSQL, MSSQL, TiDB Cloud and OceanBase.

How do I self-host SQL Chat with Docker?

Supply NEXTAUTH_SECRET and OPENAI_API_KEY, then run the published command with --platform linux/amd64 and port 3000 published. NEXTAUTH_SECRET takes an arbitrary string, since next-auth complains when it is missing. If the database is on the same host, use host.docker.internal as the host in the connection settings.

What does NEXT_PUBLIC_USE_DATABASE turn on in SQL Chat?

Setting it to true starts SQL Chat with a database, which enables the account system, per-user quota enforcement, payment and usage data collection. Use .env.nodb to run without a database for personal use and .env.usedb when you want a service like sqlchat.ai.

Can I run SQL Chat without paying for OpenAI myself?

Two settings allow it. Set OPENAI_API_ENDPOINT to a self-hosted model such as Ollama, or set NEXT_PUBLIC_ALLOW_SELF_OPENAI_KEY to true so users bring their own OpenAI API key instead of using the operator's.

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)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/sqlchat-sqlchat.svg)](https://hysenlabs.com/projects/sqlchat-sqlchat)

Was this useful?