{"uid":"cap_ylOvK6MNaPzqBrGy5nQYT","slug":"api-strale-io-4c60fa34","name":"SQL Query Generator from Natural Language","description":"Generate SQL queries from natural language descriptions. Provide table schema for best results. Supports PostgreSQL, MySQL, SQLite, MSSQL.","url":"https://api.strale.io/x402/sql-generate?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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":["natural_language_query"],"properties":{"dialect":{"type":"string","description":"postgres/mysql/sqlite/mssql"},"table_schema":{"type":"string"},"natural_language_query":{"type":"string"}}}},"additionalProperties":false}}},"responseSchema":null,"example":{"request":{"dialect":"postgresql","table_schema":"users(id, name, email, created_at), purchases(id, user_id, purchase_date, amount)","natural_language_query":"Find all users who have made at least 2 purchases in the last 90 days"},"response":{"sql":"SELECT u.id, u.name, u.email FROM users u INNER JOIN purchases p ON u.id = p.user_id WHERE p.purchase_date >= NOW() - INTERVAL '90 days' GROUP BY u.id, u.name, u.email HAVING COUNT(p.id) >= 2","_meta":{"payment":{"method":"x402","price_usd":0.054000000000000006,"settlement_id":"0xe39fa3c65478682bc689db7b1e8244e3839b4c9c0695b797e73d2cce7b0aa44c"},"capability":"sql-generate","latency_ms":1467,"provenance":{"source":"claude-haiku","fetched_at":"2026-06-13T04:25:05.951Z"}},"dialect":"postgresql","joins_used":["INNER JOIN purchases p ON u.id = p.user_id"],"explanation":"This query finds all users who have made at least 2 purchases within the last 90 days. It joins the users table with the purchases table, filters purchases from the last 90 days, groups by user, and returns only those users with 2 or more purchases in that period.","tables_referenced":["users","purchases"],"estimated_complexity":"simple"}},"exampleRequest":{"dialect":"postgresql","table_schema":"users(id, name, email, created_at), purchases(id, user_id, purchase_date, amount)","natural_language_query":"Find all users who have made at least 2 purchases in the last 90 days"},"tags":["x402"],"displayCostAmount":"0.054001","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","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.054001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.054","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.054","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_bC8PpUjyzBnN45l-uq5DY","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.054","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Converts a natural language description into a SQL query, optionally using a provided table schema and targeting a specific SQL dialect (PostgreSQL, MySQL, SQLite, MSSQL).","exampleAgentPrompt":"Write me a PostgreSQL query to find all customers who placed more than 3 orders in the last 30 days — here's my schema: customers(id, name, email), orders(id, customer_id, created_at, total).","exampleUseCases":null,"resultDescription":"A generated SQL query string tailored to the specified dialect and table schema, ready to run against a database. May include JOINs, WHERE clauses, aggregations, or other constructs matching the natural language intent.","failureModes":["Ambiguous natural language query leads to incorrect SQL logic","Missing or incorrect table schema causes hallucinated column/table names","Unsupported dialect or typo in dialect parameter causes fallback or error","Query too complex for single-pass generation (e.g., deeply nested subqueries)","No natural_language_query provided returns a 400/validation error"],"whenToPreferThis":"Choose this endpoint when you need to quickly convert a plain-English database question into executable SQL, especially when you have a known table schema and a target dialect (PostgreSQL, MySQL, SQLite, MSSQL). Ideal for agents helping non-technical users query databases or for automating query generation in data pipelines.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-10T12:35:47.473Z","isFirstParty":false,"canonicalSlug":"api-strale-io-4c60fa34"}