# JSON Schema Inference API

> JSON Schema Inference API is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.004/call, status unknown (last checked 2026-09-15).

Infers a JSON Schema (draft 2020-12) from one or more sample JSON documents, detecting types, nested structures, arrays, and required fields.

## Facts

- Endpoint: POST https://api.24klabs.ai/api/v1/json-schema-infer
- Price: $0.004/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/json-schema-inference-api-2cf92124
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_ZrQyd1cVaMHP053CmkMMt

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 json-schema-inference-api-2cf92124 -d '<json body>'
```

Example prompt: Look at these two JSON objects I pasted and infer a JSON Schema draft 2020-12 for them — make sure to detect any type unions, required fields, and nested arrays: {"id":1,"name":"Alice","tags":["admin"]} and {"id":2,"name":null,"tags":[]}

## When to prefer this

Choose this endpoint when you need to automatically derive a JSON Schema draft 2020-12 from real example data without writing the schema by hand, especially when you have multiple samples and want accurate required-field detection and type-union inference. Prefer it over manual schema authoring or generic LLM prompting when precision and draft-2020-12 compliance matter.

## Known failure modes

- Invalid or malformed JSON input returns a parsing error
- Empty input array returns an error or minimal schema
- Highly inconsistent samples may produce overly permissive schemas with many type unions
- Very deeply nested structures may hit recursion limits
- Single sample may miss optional fields, producing overly strict required lists

## How this service works

Infer a JSON Schema (draft 2020-12) from one or more sample documents: type unions, nested objects/arrays, and required-field detection.

## Output

Returns a JSON Schema (draft 2020-12) object derived from the provided sample documents, including inferred property types (with type unions where values vary), identification of required vs optional fields based on presence across samples, and full handling of nested objects and arrays.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "samples": {
   "type": "array"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "schema": {
   "type": "object",
   "required": [
    "id",
    "name"
   ]
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/json-schema-inference-api-2cf92124/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)
