# Aayat AI SQL Explain & Sanity Check

> Aayat AI SQL Explain & Sanity Check is a paid API for AI agents from aayatai.com, paid per call via x402, $0.003/call, status unknown (last checked 2026-10-02).

Analyzes a SQL query for statement type, tables touched, syntax errors, risky patterns, and returns a plain-English explanation plus a safety verdict.

## Facts

- Endpoint: POST https://aayatai.com/sql/explain?utm_source=zero.xyz
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-02
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/aayat-ai-sql-explain-sanity-check-b00d1371
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_gB9kwia1bDE73yC1saAya

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 aayat-ai-sql-explain-sanity-check-b00d1371 -d '<json body>'
```

Example prompt: 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'

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

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}.

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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)."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "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."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/aayat-ai-sql-explain-sanity-check-b00d1371/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from aayatai.com](https://www.zero.xyz/host/aayatai.com/llms.txt)
