# 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-14).

Converts a plain-English question or request into a SQL query, optionally using a provided schema for accurate table joins.

## Facts

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

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-200703d9 -d '<json body>'
```

Example prompt: Turn this into a SQL query for me: 'show me 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).

## When to prefer this

Choose this endpoint when you need to translate natural language questions into executable SQL on demand, especially when you can supply a database schema for accurate join and column resolution. Ideal for building no-code data tools, agent-driven analytics, or rapid prototyping where writing SQL manually would slow down the workflow. Prefer over general LLM completions when you want a dedicated, cost-predictable SQL generation microservice.

## Known failure modes

- Ambiguous natural language input results in a plausible but incorrect query
- Without a schema, table/column names may be guessed incorrectly
- Complex multi-step queries may produce simplified or incomplete SQL
- Dialect-specific syntax (PostgreSQL vs MySQL vs SQLite) may not match target database if not specified
- Malformed or incomplete schema input may cause join inference errors

## How this service works

Convert a plain-English request into a SQL query; pass an optional schema for accurate joins.

## Output

Returns a SQL query string corresponding to the plain-English input, structured to be syntactically correct and (when a schema is provided) accurately referencing real table and column names with proper JOINs, WHERE clauses, and aggregations.

## 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-200703d9/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)
