# SQL Query Generator from Natural Language

> SQL Query Generator from Natural Language is a paid API for AI agents from api.strale.io, paid per call via x402, $0.054001/call, status unknown (last checked 2026-10-10).

Converts a natural language description into a SQL query, optionally using a provided table schema and targeting a specific SQL dialect (PostgreSQL, MySQL, SQLite, MSSQL).

## Facts

- Endpoint: GET https://api.strale.io/x402/sql-generate?utm_source=zero.xyz
- Price: $0.054001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-strale-io-4c60fa34
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_ylOvK6MNaPzqBrGy5nQYT

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability api-strale-io-4c60fa34
```

Example prompt: Write me a PostgreSQL query to find all customers who placed more than 3 orders in the last 30 days — here's my schema: customers(id, name, email), orders(id, customer_id, created_at, total).

## When to prefer this

Choose this endpoint when you need to quickly convert a plain-English database question into executable SQL, especially when you have a known table schema and a target dialect (PostgreSQL, MySQL, SQLite, MSSQL). Ideal for agents helping non-technical users query databases or for automating query generation in data pipelines.

## Known failure modes

- Ambiguous natural language query leads to incorrect SQL logic
- Missing or incorrect table schema causes hallucinated column/table names
- Unsupported dialect or typo in dialect parameter causes fallback or error
- Query too complex for single-pass generation (e.g., deeply nested subqueries)
- No natural_language_query provided returns a 400/validation error

## How this service works

Generate SQL queries from natural language descriptions. Provide table schema for best results. Supports PostgreSQL, MySQL, SQLite, MSSQL.

## Output

A generated SQL query string tailored to the specified dialect and table schema, ready to run against a database. May include JOINs, WHERE clauses, aggregations, or other constructs matching the natural language intent.

## Example request

```json
{
 "dialect": "postgresql",
 "table_schema": "users(id, name, email, created_at), purchases(id, user_id, purchase_date, amount)",
 "natural_language_query": "Find all users who have made at least 2 purchases in the last 90 days"
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET",
      "HEAD",
      "DELETE"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "natural_language_query"
     ],
     "properties": {
      "dialect": {
       "type": "string",
       "description": "postgres/mysql/sqlite/mssql"
      },
      "table_schema": {
       "type": "string"
      },
      "natural_language_query": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-strale-io-4c60fa34/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.strale.io](https://www.zero.xyz/host/api.strale.io/llms.txt)
