# 24K Labs Text-to-SQL

> 24K Labs Text-to-SQL is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.02/call, status unknown (last checked 2026-09-13).

Converts a natural language question into a SQL query using AI

## Facts

- Endpoint: POST https://api.24klabs.ai/api/text-to-sql
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/24k-labs-text-to-sql-35d59bd6
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__hzbVWapdLHAPHET5-KCd

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 24k-labs-text-to-sql-35d59bd6 -d '<json body>'
```

Example prompt: Convert this question into SQL for me: 'What are the top 10 customers by total revenue in the last 90 days?' — my tables are customers(id, name) and orders(id, customer_id, amount, created_at).

## When to prefer this

Choose this endpoint when you need to programmatically convert natural language questions into SQL queries at low cost ($0.02 per call), especially in agentic workflows where users without SQL knowledge need to query relational databases. It is ideal for building self-service analytics tools, chatbot database interfaces, or automating report generation from plain-English descriptions.

## Known failure modes

- Ambiguous natural language input produces an incorrect or unexpected SQL query
- Missing or incomplete schema context leads to generic or hallucinated table/column names
- Complex multi-join queries may be incomplete or syntactically incorrect
- API returns error if required fields (question/schema) are missing
- Rate limits or payment failures may result in 402 or 429 errors

## How this service works

A curated directory of x402 services — each one on the list on purpose, with the health, uptime, and independent trust grades from across the ecosystem gathered in one place.

## Output

Returns a JSON object containing a 'sql' field with a complete, ready-to-run SQL query (typically a SELECT statement) generated from the input natural language question.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "schema": {
   "type": "string"
  },
  "dialect": {
   "type": "string"
  },
  "request": {
   "type": "string"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "sql": "SELECT ..."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/24k-labs-text-to-sql-35d59bd6/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.24klabs.ai](https://www.zero.xyz/host/api.24klabs.ai/llms.txt)
