# JSON to Pydantic Model Converter

> JSON to Pydantic Model Converter is a paid API for AI agents from api.strale.io, paid per call via x402, $0.054001/call, status unknown (last checked 2026-10-10).

Converts a JSON object or JSON string into Python Pydantic model class definitions, handling nested objects, arrays, and optional fields algorithmically.

## Facts

- Endpoint: GET https://api.strale.io/x402/json-to-pydantic?utm_source=zero.xyz
- Price: $0.054001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-10
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-strale-io-6a3806af
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_rliR5QhFHfXj5G1G1nrFh

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 api-strale-io-6a3806af
```

Example prompt: Can you convert this JSON into Python Pydantic model classes? {"user": {"id": 1, "name": "Alice", "address": {"city": "NYC", "zip": "10001"}, "tags": ["admin", "user"]}} — name the root model 'UserModel'.

## When to prefer this

Use this endpoint when you need to quickly scaffold Pydantic model classes from a real JSON example or API response, especially when working in Python and needing type-safe data validation. Prefer this over manual authoring when the JSON has nested objects or arrays that would be tedious to model by hand.

## Known failure modes

- Invalid or malformed JSON input returns an error
- Missing required 'json' query parameter returns 400
- Very deeply nested JSON may hit complexity limits
- Empty JSON object may produce minimal or empty model

## How this service works

Convert JSON to Python Pydantic model classes. Handles nested objects, arrays, optional fields. Algorithmic.

## Output

Python source code containing Pydantic BaseModel class definitions corresponding to the input JSON structure, with proper field names, type annotations, nested model classes, and optional field handling.

## Example request

```json
{
 "json": "{\"user\": {\"id\": 1, \"name\": \"Alice\", \"email\": \"alice@example.com\", \"is_active\": true, \"tags\": [\"admin\", \"user\"]}}",
 "root_name": "UserModel"
}
```

## 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": [
      "json"
     ],
     "properties": {
      "json": {
       "description": "JSON string or object"
      },
      "root_name": {
       "type": "string"
      }
     }
    }
   },
   "additionalProperties": false
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-strale-io-6a3806af/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)
