Skip to main content
Use json when your code reads fields rather than text. A schema fixes the names and types. A prompt lets the model choose names, so they can differ between calls. schema and prompt need an API key.
A field the page does not state comes back null, and each value is checked against the page text.

Fields of the json format

  • The model reads the first 50,000 characters of the Markdown.
  • A json format with none of schema, prompt, rules or parser returns 400 invalidRequest. So does rules with schema, prompt or parser.
  • When the page states none of your fields, the model fee is not charged.

Rules and attributes

"formats": [{ "type": "json", "rules": { "title": "h1", "links": { "selector": "a", "type": "list", "output": "@href" } } }] reads the page with CSS and no model. A missing item is null, an unmatched list is [], and relative links become absolute. It works without a key. { "type": "attributes", "selectors": [{ "selector": "a", "attribute": "href" }] } reads attribute values. Send 1 to 50 entries. data.attributes has one entry per selector with its selector, attribute and the values it found.

Product and menu

"formats": ["product"] reads a product page. data.product has title, brand, category, url, description and variants. Price, sale, stock and images belong to a variant, and a product with no options has one. "formats": ["menu"] reads a restaurant menu. data.menu has isMenu, confidence (0 to 1), merchant (name, type), currency and sections. Each section has name, description and items. An item has name, description, price, availability, dietary, calories, images, url and optionGroups, each group a name with options that have a name and a price. A field the page does not state is left out. When the page is not a product page, product is left out and data.warning says why. The same holds for menu. The model reads the first 50,000 characters of the Markdown. schema, prompt, product and menu add a fee when they return something. rules, parser and attributes add none. See Pricing.