{"uid":"cap_ZrQyd1cVaMHP053CmkMMt","slug":"json-schema-inference-api-2cf92124","name":"JSON Schema Inference API","description":"Infer a JSON Schema (draft 2020-12) from one or more sample documents: type unions, nested objects/arrays, and required-field detection.","url":"https://api.24klabs.ai/api/v1/json-schema-infer","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"samples":{"type":"array"}}},"responseSchema":{"type":"json","example":{"schema":{"type":"object","required":["id","name"]}}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.004/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.004","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_R4do0pkfAn9sczSAbqzHa","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.004","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Infers a JSON Schema (draft 2020-12) from one or more sample JSON documents, detecting types, nested structures, arrays, and required fields.","exampleAgentPrompt":"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\":[]}","exampleUseCases":[{"title":"API contract generation from examples","prompt":"I have three sample API response payloads and I want you to infer a JSON Schema draft 2020-12 from them so I can use it for validation — here they are: [{\"userId\":1,\"email\":\"a@b.com\",\"active\":true},{\"userId\":2,\"email\":\"c@d.com\",\"active\":false},{\"userId\":3,\"email\":\"e@f.com\"}]"},{"title":"Detecting required vs optional fields","prompt":"Can you analyze these JSON samples and tell me which fields are always present (required) vs sometimes missing, and generate a JSON Schema for it? Here's the data: [{\"name\":\"Widget\",\"price\":9.99,\"sku\":\"W1\"},{\"name\":\"Gadget\",\"price\":19.99},{\"name\":\"Doohickey\",\"price\":4.99,\"sku\":\"D3\"}]"},{"title":"Schema inference for nested document structure","prompt":"I've got some nested JSON documents with arrays and sub-objects and I need a JSON Schema draft 2020-12 inferred from them — including the nested types: [{\"order\":{\"id\":100,\"items\":[{\"product\":\"Apple\",\"qty\":2}]},\"status\":\"shipped\"},{\"order\":{\"id\":101,\"items\":[{\"product\":\"Banana\",\"qty\":1},{\"product\":\"Cherry\",\"qty\":5}]},\"status\":\"pending\"}]"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T00:43:34.719Z","isFirstParty":false}