{"uid":"cap_af2FHSwz7DEDnNUMJtD2x","slug":"sitecheck-sql-generator-0efdfa6d","name":"SiteCheck SQL Generator","description":"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.","url":"https://api.sitecheck-api.workers.dev/api/sql/generate?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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)"}}},"responseSchema":{"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."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.003","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.003/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Cg9efFnxw_UjCeLgiY30T","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Converts a plain-language question and a database schema into a syntactically correct SQL query for Postgres, MySQL, SQLite, or BigQuery","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Analytics query for order reporting","prompt":"I have a Postgres database with these tables: CREATE TABLE orders (id SERIAL, placed_at TIMESTAMP, status TEXT, total NUMERIC); CREATE TABLE customers (id SERIAL, email TEXT, country TEXT); — can you generate a SQL query that shows total revenue by country for orders with status 'completed' in the last 6 months?"},{"title":"Read-only dashboard query generation","prompt":"Given this SQLite schema — CREATE TABLE sessions (id INTEGER PRIMARY KEY, user_id INTEGER, started_at TEXT, duration_seconds INTEGER); — write me a query that finds the average session duration per user for sessions longer than 60 seconds, and make sure it's read-only."},{"title":"BigQuery query from plain question","prompt":"My BigQuery table is defined as CREATE TABLE events (event_id STRING, user_id STRING, event_type STRING, occurred_at TIMESTAMP, properties JSON); — generate a BigQuery SQL query that counts unique users who triggered a 'purchase' event each day this year."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-20T13:01:13.164Z","isFirstParty":false,"canonicalSlug":"sitecheck-sql-generator-0efdfa6d"}