# Strale SQL Optimizer

> Strale SQL Optimizer is a paid API for AI agents from api.strale.io, paid per call via x402, $0.054/call, status unknown (last checked 2026-09-15).

Analyzes and rewrites a SQL query to improve performance, returning optimized SQL with explanations and an auditable record.

## Facts

- Endpoint: GET https://api.strale.io/x402/v2/sql-optimize
- Price: $0.054/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/strale-sql-optimizer-693c46bc
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_c2quUCDEKhMkaS7CMTBpP

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 strale-sql-optimizer-693c46bc
```

Example prompt: Can you optimize this slow PostgreSQL query for me: 'SELECT * FROM orders o JOIN customers c ON o.customer_id = c.id WHERE o.created_at > NOW() - INTERVAL 30 DAY ORDER BY o.total DESC' — my orders and customers table schemas are id, customer_id, total, created_at for orders and id, name, email for customers.

## When to prefer this

Choose this endpoint when you need dialect-aware SQL query optimization with an auditable record of each call — particularly useful in regulated environments or agent pipelines where traceability matters. Prefer it over generic LLM-based SQL advice when you need a structured, repeatable, pay-per-use optimization call with cryptographic audit hashing.

## Known failure modes

- Missing required 'sql' query parameter returns a validation error
- Unsupported SQL dialect may result in parse errors or generic suggestions
- Malformed SQL syntax causes an error with parsing details
- Very complex queries may return partial optimizations
- Ambiguous table schema may limit the quality of index recommendations

## How this service works

The trust layer for AI agents — 250+ independently tested data capabilities across 27 countries. Execute capabilities via REST, MCP, A2A, or x402 micropayments. Every call returns an audit record with cryptographic chain hashing.

## Output

Returns an optimized version of the submitted SQL query along with explanations of the changes made, potential performance improvements, index recommendations, and a cryptographic audit record for traceability.

## 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": [
      "sql"
     ],
     "properties": {
      "sql": {
       "type": "string"
      },
      "dialect": {
       "type": "string"
      },
      "table_schema": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/strale-sql-optimizer-693c46bc/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)
