schema is a JSON Schema that names the fields you want. The output of Pydantic’s model_json_schema() and zod’s toJSONSchema() works as it is, so one model can describe the request and read the answer.
Send a model
Get an API key in the Quickstart. This request fills the fields of a model from one page. The cURL tab shows the JSON Schema that zod writes for the model in the TypeScript tab, and Pydantic writes an equivalent one.showSources asks for the page behind each value. See Results.
data. That is why the TypeScript tab reads the answer with partial() and the Python model gives every field a default.
Read the response
GET /v1/extract/{id} returns the fields you asked for, a confidence for each, and sources because the request sent showSources.
pricePerMonth is not in data, confidence or sources: the page does not state it. Each value that is returned is checked against the page text. A value that is not found there is dropped, and so is a value that does not fit its schema, such as a word that is not in an enum.
What a schema can say
Both drafts work: draft-07 and 2020-12.
Options
Send a
schema, a prompt, or both. With a prompt and no schema, the model names up to 20 fields in camelCase.
Limits and errors
- A call with neither a
schemanor apromptreturns400 invalidRequestwithSend a schema, a prompt, or both. - A schema with no
properties, and no$refto an object that has them, returns400 invalidRequestwithSend a JSON Schema object with properties, or one whose $ref points at such an object. - More than 100 top-level fields returns
400 invalidRequestwithAsk for at most 100 fields. A schema over 32 KB returnsKeep the schema under 32 KB, and one more than 32 levels deep returnsNest the schema at most 32 levels deep. - A schema that is not valid JSON Schema returns
400 invalidRequestwithThe schema is not valid JSON Schemaand the reason. - A call that finds none of your fields costs nothing.
Related
- Extract overview lists every request field.
- Results reads the answer back, with sources, timeouts and a webhook.
- JSON fills the same kind of schema from one page inside a scrape.
- Agent fills a schema from pages it finds itself.