{"uid":"cap_gB9kwia1bDE73yC1saAya","slug":"aayat-ai-sql-explain-sanity-check-b00d1371","name":"Aayat AI SQL Explain & Sanity Check","description":"Explain and sanity-check a SQL query before running it: statement type, tables touched, syntax problems (quotes, parentheses, = NULL), risky patterns (UPDATE/DELETE without WHERE, DROP, NOT IN with NULLs, cartesian joins, non-sargable filters, multiple statements) and a plain-English explanation. POST {sql, dialect}.","url":"https://aayatai.com/sql/explain?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"sql":{"type":"string","maxLength":8000,"minLength":5,"description":"The SQL to check."},"dialect":{"enum":["postgres","mysql","sqlite","sqlserver","generic"],"type":"string","default":"generic","description":"SQL dialect (used in the explanation)."}}},"responseSchema":{"type":"json","example":{"type":"DELETE","valid":true,"tables":["users"],"verdict":"ok","findings":[],"statements":1,"explanation":"Deletes every user whose last login was more than two years ago."}},"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_FpYyI0oXFPcWR4fo9AJxu","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":"Analyzes a SQL query for statement type, tables touched, syntax errors, risky patterns, and returns a plain-English explanation plus a safety verdict.","exampleAgentPrompt":"Before I run this query, can you sanity-check it for risky patterns and explain what it does in plain English? It's a postgres query: DELETE FROM users WHERE last_login < NOW() - INTERVAL '2 years'","exampleUseCases":[{"title":"Pre-flight check before production DELETE","prompt":"I'm about to run this on our production database — can you check it for anything dangerous and explain what it actually does? SQL: DELETE FROM orders WHERE status = 'cancelled', dialect is postgres."},{"title":"Review LLM-generated SQL before execution","prompt":"An AI generated this query for me and I want to make sure it's safe before I run it. Check for syntax issues, risky patterns, and give me a plain English explanation: SELECT * FROM customers, purchases WHERE customers.id = purchases.customer_id, dialect is mysql."},{"title":"Teach a junior dev what a complex query does","prompt":"Can you explain this SQL in plain English and flag any problems? It's a SQLite query: UPDATE accounts SET balance = balance - 100 WHERE account_type = 'trial'."}],"resultDescription":"A JSON object containing: the statement type (e.g. DELETE, SELECT), a validity boolean, a list of tables touched, a verdict string (ok/warn/error), an array of findings describing any syntax or risk issues found, a count of statements, and a plain-English explanation of what the query does.","failureModes":["SQL string shorter than 5 characters returns validation error","SQL string exceeding 8000 characters is rejected","Unsupported dialect value causes a schema validation error","Malformed JSON body returns 400","Payment not included or insufficient results in 402 Payment Required","Ambiguous multi-statement SQL may produce partial analysis"],"whenToPreferThis":"Use this endpoint when an agent or user wants to validate and understand a SQL query before executing it — especially when the query was generated by an LLM, came from an untrusted source, or involves destructive operations like UPDATE, DELETE, or DROP. Prefer this over generic LLM SQL explanation when you need structured output (verdict, findings array, tables list) that can be acted on programmatically, or when you want dialect-aware analysis across postgres, mysql, sqlite, sqlserver, or generic SQL.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-02T00:44:14.981Z","isFirstParty":false,"canonicalSlug":"aayat-ai-sql-explain-sanity-check-b00d1371"}