# SiteCheck SQL Generator

> SiteCheck SQL Generator is a paid API for AI agents from api.sitecheck-api.workers.dev, paid per call via x402, $0.003/call, status unknown (last checked 2026-10-20).

Converts a plain-language question and a database schema into a syntactically correct SQL query for Postgres, MySQL, SQLite, or BigQuery

## Facts

- Endpoint: POST https://api.sitecheck-api.workers.dev/api/sql/generate?utm_source=zero.xyz
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-20
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/sitecheck-sql-generator-0efdfa6d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_af2FHSwz7DEDnNUMJtD2x

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 sitecheck-sql-generator-0efdfa6d -d '<json body>'
```

Example prompt: Using my Postgres database with this schema — CREATE TABLE orders (id SERIAL PRIMARY KEY, placed_at TIMESTAMP, customer_id INT, total NUMERIC); — write me a SQL query that counts how many orders were placed in 2025.

## When to prefer this

Choose this endpoint when you need to translate a plain-language data question into a syntactically correct SQL query against a known schema, particularly within an AI agent pipeline where writing SQL manually is impractical. It supports multiple dialects (Postgres, MySQL, SQLite, BigQuery), safely defaults to read-only queries, and returns column-level metadata useful for auditing. Prefer it over general-purpose LLM SQL generation when you want a pay-per-call, schema-grounded, structured response with explicit table and column references.

## Known failure modes

- Schema exceeds 20,000 character limit — request rejected
- Question exceeds 1,000 character limit — request rejected
- Ambiguous or underspecified question may produce incorrect SQL — review carefully
- Unsupported dialect requested — defaults to postgres or errors
- Schema syntax errors may cause malformed SQL output
- allowWrite=false but write-type question asked — query may be refused or rewritten as read-only

## How this service works

SQL from a question and a schema (CREATE TABLE statements or a JSON description of tables and columns), for postgres (default), mysql, sqlite or bigquery. The tables and columns used are checked against the schema; a query that does not match it is retried once, then refused. Writes (INSERT, UPDATE, DELETE, DDL) are refused unless allowWrite is true. The query is not run.

## Output

Returns a JSON object containing the generated SQL string, a human-readable explanation of what the query does, the list of tables and columns referenced, the SQL dialect used, a readOnly boolean flag, a timestamp, and an advisory note reminding the caller to review the SQL before execution since it was not actually run.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "schema": {
   "type": "string",
   "description": "CREATE TABLE statements, or a JSON object of tables and column lists (max 20,000 characters)"
  },
  "dialect": {
   "type": "string",
   "description": "postgres (default), mysql, sqlite or bigquery"
  },
  "question": {
   "type": "string",
   "description": "Question in plain language (max 1,000 characters)"
  },
  "allowWrite": {
   "type": "boolean",
   "description": "Allow INSERT, UPDATE, DELETE or DDL (default false)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "sql": "SELECT COUNT(id) FROM orders WHERE EXTRACT(YEAR FROM placed_at) = 2025",
  "note": "The query was not run. Tables and columns were checked against the schema you gave; review the SQL before running it.",
  "tables": [
   "orders"
  ],
  "columns": [
   {
    "table": "orders",
    "column": "id"
   },
   {
    "table": "orders",
    "column": "placed_at"
   }
  ],
  "dialect": "postgres",
  "readOnly": true,
  "checkedAt": "2026-10-15T18:21:17.416Z",
  "explanation": "This query counts the number of rows in the orders table where the year of the placed_at timestamp is 2025."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/sitecheck-sql-generator-0efdfa6d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.sitecheck-api.workers.dev](https://www.zero.xyz/host/api.sitecheck-api.workers.dev/llms.txt)
