Public API

Generate SQL and NoSQL queries from your own application.

API keys are tied to your account

Sign in to create a key and send your first request. API access is included in paid plans.

Sign in to create a key

Quick start

The endpoint accepts JSON and answers with { query, error }. See the full documentation for every option.

const response = await fetch('https://api.sqlai.ai/v2', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer YOUR_API_KEY',
  },
  body: JSON.stringify({
    prompt: 'Get user with id 13',
    engine: 'postgres',
    engineVersion: '17',
    dataSource: [
      { table: 'users', column: 'id', type: 'bigint' },
      { table: 'users', column: 'name', type: 'text' },
    ],
  }),
});

const { query, error } = await response.json();
console.log(query);

What you get

Your schema

Attach a database by id or send the schema inline as an array or string.

SQL and NoSQL

Text-to-SQL for every SQL dialect, plus MongoDB command objects.

Credits

Each request uses one generation from the plan on your account.

Private

Only you can use your keys, and requests never see other accounts.

Need a higher rate limit or a volume contract? Talk to us.