json returns an object in the shape you describe, filled from the text of the page. Describe it with a JSON Schema, or with a prompt in plain words.
Fill a schema
Get an API key in the Quickstart. Sendjson as an object with a schema. This request reads three facts from a documentation page.
Read the response
data.json holds the fields of your schema.
null. Each value is checked against the page text before it is returned.
Fill a prompt
When you do not want to write a schema, send aprompt. The model picks the field names and returns up to 20 fields.
schema when your code reads the fields by name, because a prompt can name fields differently from one call to the next.
Read attributes
To read attribute values such as link URLs, send theattributes format. It uses no model and adds no charge. Each entry in selectors names the elements to match with a CSS selector and the attribute to read. Send 1 to 50 entries. This request reads the URL of every link on a page.
data.attributes has one entry for each selector you sent, with its selector, its attribute and the values it found. The read costs $1 per 1,000 pages. attributes adds nothing.
Options
Pydantic’s
model_json_schema() and zod’s toJSONSchema() output work as they are. enum, const, anyOf, oneOf, nullable types, $ref with $defs, required and description are all read.
Limits and errors
- The model reads the first 50,000 characters of the page’s Markdown.
- A
jsonformat with noschema,prompt,rulesorparserreturns400 invalidRequestwith the messageformats: json needs a schema or a prompt for this page. rulestogether withschema,promptorparserreturns400 invalidRequestwith the messagerules cannot be combined with schema, prompt or parser.- If the page states none of your fields, the model fee is not charged.
Price
$4 per 1,000 pages: $1 for the page and $3 forjson with a schema or a prompt. rules, parser and attributes add nothing.
Related
- Pre-built parsers return a site’s own data as JSON.
- Product returns a product page in a fixed shape.
- Extract pulls fields from one or more pages and checks each against the page.
- Question answers one question in a sentence.