# Inference402 Structured JSON Chat

> Inference402 Structured JSON Chat is a paid API for AI agents from inference402.worlddata402.workers.dev, paid per call via x402, $0.01/call, status unknown (last checked 2026-10-19).

Generate LLM responses constrained to a caller-supplied JSON Schema, using Llama 3.3 70B, paid per-call via USDC on Base mainnet with no API key required.

## Facts

- Endpoint: GET https://inference402.worlddata402.workers.dev/v1/chat/json?utm_source=zero.xyz
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-19
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/inference402-structured-json-chat-e51971c2
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_PDoMkjfdJ8vl4LcYIl1WB

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 inference402-structured-json-chat-e51971c2
```

Example prompt: Extract the person's name, age, and city from this text into structured JSON — 'My name is Sara Ahmed, I am 34 years old and I live in Alexandria' — use the schema {name: string, age: integer, city: string} and keep it under 256 tokens.

## When to prefer this

Choose this endpoint when you need LLM output that must conform to a specific JSON Schema without post-processing — especially in agentic pipelines where downstream code consumes typed data. It is ideal when you have no existing AI API key, want pay-per-call billing in USDC with no subscription, and need schema validation built into the inference loop. Prefer alternatives if you need streaming responses, very large token outputs (>768), or integration with OpenAI-compatible SDKs.

## Known failure modes

- Schema too large (>4000 chars serialized) causes rejection
- Messages array empty or exceeds 50 items
- max_tokens out of range (must be 1–768)
- Payment failure or insufficient USDC balance on Base mainnet blocks the call
- Model fails to produce schema-valid JSON after retry attempts, returning valid: false
- Malformed JSON Schema causes parse errors
- Rate limiting or Cloudflare Worker timeout on complex schemas

## How this service works

Pay-per-call AI inference for agents: chat (Llama 3.3 70B / 3.1 8B), structured JSON, summarize, translate (incl. Egyptian Arabic), extract, classify, sentiment, keywords, rewrite, embeddings, moderation, vision and speech-to-text. USDC on Base mainnet over x402. No API key, no account.

## Output

A JSON object with a 'data' field containing the schema-validated response, a 'model' field indicating which Llama model was used, a 'valid' boolean confirming schema compliance, and an 'attempts' integer showing how many inference retries were needed to produce a valid result.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "schema": {
   "type": "object",
   "description": "JSON Schema the output must satisfy (≤4000 chars when serialized)"
  },
  "messages": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "role",
     "content"
    ],
    "properties": {
     "role": {
      "enum": [
       "system",
       "user",
       "assistant"
      ],
      "type": "string"
     },
     "content": {
      "type": "string"
     }
    }
   },
   "maxItems": 50,
   "minItems": 1
  },
  "max_tokens": {
   "type": "integer",
   "default": 512,
   "maximum": 768,
   "minimum": 1
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "data": {
   "age": 34,
   "city": "Alexandria",
   "name": "Sara Ahmed"
  },
  "model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
  "valid": true,
  "attempts": 1
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/inference402-structured-json-chat-e51971c2/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from inference402.worlddata402.workers.dev](https://www.zero.xyz/host/inference402.worlddata402.workers.dev/llms.txt)
