SQL Generator

Write SQL from a plain-language request. Give it your table schema for best results. Supports PostgreSQL, MySQL, SQLite and SQL Server.

Pay by wallet (x402) AI-generated sql-generate

Example

Example answer
{
  "sql": "SELECT * FROM users WHERE active = true;",
  "dialect": "postgres",
  "joins_used": [],
  "explanation": "This query retrieves all active users from the users table, selecting all columns (id, name, email, active, created_at) for users where the active flag is set to true.",
  "tables_referenced": [
    "users"
  ],
  "estimated_complexity": "simple"
}

Inputs

FieldTypeRequiredWhat it is
dialectstringNopostgres/mysql/sqlite/mssql
table_schemastringNo—
natural_language_querystringYes—

Output fields

How reliably each field appears in a successful answer.

FieldTypeAppears
sqlstringAlways (present in every successful answer)
explanationstringAlways (present in every successful answer)
tables_referencedarrayAlways (present in every successful answer)
estimated_complexitystringAlways (present in every successful answer)

How to call it

The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.

# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
  -H "Authorization: Bearer $STRALE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "capability_slug": "sql-generate",
    "inputs": {
      "dialect": "postgres",
      "table_schema": "users(id INT, name TEXT, email TEXT, active BOOL, created_at TIMESTAMP)",
      "natural_language_query": "en"
    },
    "max_price_cents": 5
  }'

Limitations

  • Complex queries need testing against your schema

    AI-generated SQL — complex joins and subqueries should be tested against your schema before running on production

    What to do instead: Test generated queries against a staging database with representative data volume to verify correctness and performance