{
  "openapi": "3.0.1",
  "info": {
    "title": "AI Web Scraper: Web Page to JSON with OpenAI or Claude",
    "description": "AI web scraper that turns any web page into structured JSON. Give URLs and the fields you want (or a JSON schema) and your own OpenAI, Claude, Grok or OpenRouter key extracts validated rows, with auto-retry on bad JSON. Pay only for pages that match.",
    "version": "1.0",
    "x-build-id": "AcI5bmC7hv7KrPuai"
  },
  "servers": [
    {
      "url": "https://api.apify.com/v2"
    }
  ],
  "paths": {
    "/acts/mosaicked_sponge~ai-schema-extractor/run-sync-get-dataset-items": {
      "post": {
        "operationId": "run-sync-get-dataset-items-mosaicked_sponge-ai-schema-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/acts/mosaicked_sponge~ai-schema-extractor/runs": {
      "post": {
        "operationId": "runs-sync-mosaicked_sponge-ai-schema-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor and returns information about the initiated run in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/runsResponseSchema"
                }
              }
            }
          }
        }
      }
    },
    "/acts/mosaicked_sponge~ai-schema-extractor/run-sync": {
      "post": {
        "operationId": "run-sync-mosaicked_sponge-ai-schema-extractor",
        "x-openai-isConsequential": false,
        "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
        "tags": [
          "Run Actor"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/inputSchema"
              }
            }
          }
        },
        "parameters": [
          {
            "name": "token",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Enter your Apify token here"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "inputSchema": {
        "type": "object",
        "properties": {
          "startUrls": {
            "title": "Start URLs",
            "type": "array",
            "description": "Pages to extract from, one per line (https:// is added if missing). Each page becomes one result row. Duplicates and invalid entries are skipped for free.",
            "items": {
              "type": "string"
            }
          },
          "fields": {
            "title": "Fields to extract (simple)",
            "type": "array",
            "description": "One field per line: \"name\", \"name: type\" or \"name: type - description\". Types: string (default), number, integer, boolean, or a list such as string[]. Example: \"price: number - price in USD\". Ignored when a JSON schema is given below.",
            "items": {
              "type": "string"
            }
          },
          "schema": {
            "title": "JSON schema (advanced, overrides the field list)",
            "type": "object",
            "description": "A full JSON Schema (draft 2020-12) for one page's result, e.g. {\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"price\":{\"type\":\"number\"}},\"required\":[\"name\"]}. Shorthand {\"name\":\"string\",\"price\":\"number\"} also works. Every AI answer is validated against it."
          },
          "extractMany": {
            "title": "Extract ALL matching items on each page (lists)",
            "type": "boolean",
            "description": "On: the fields/schema describe ONE item and the result is {\"items\": [...]} with every matching item on the page (e.g. all products on a category page, all jobs on a careers page). Still one row (and one charge) per page.",
            "default": false
          },
          "instructions": {
            "title": "Instructions (optional)",
            "type": "string",
            "description": "Extra guidance for the model, e.g. \"Prices are in EUR; convert '1.299,00' to 1299.00\" or \"Only include products that are in stock\". With no fields or schema, the model returns free-form JSON following these instructions."
          },
          "apiKey": {
            "title": "Your AI API key (OpenAI, Anthropic, xAI or OpenRouter)",
            "type": "string",
            "description": "Your own key: sk-... (OpenAI), sk-ant-... (Anthropic), xai-... (xAI / Grok) or sk-or-... (OpenRouter). The provider is detected from the key. You pay your provider directly for tokens. Stored encrypted by Apify, sent only to your AI provider, never logged or saved in results. Leave empty for a free preview (basic page facts without AI, first 2 URLs only)."
          },
          "provider": {
            "title": "AI provider",
            "enum": [
              "auto",
              "openai",
              "anthropic",
              "openrouter",
              "xai"
            ],
            "type": "string",
            "description": "Auto detects the provider from the key prefix. Pick one explicitly for keys without a standard prefix.",
            "default": "auto"
          },
          "model": {
            "title": "Model",
            "type": "string",
            "description": "Model name at your provider. Empty = a fast, cheap default: gpt-4o-mini (OpenAI), claude-haiku-4-5 (Anthropic), grok-4.20-non-reasoning (xAI), openai/gpt-4o-mini (OpenRouter). Examples: gpt-4.1-mini, gpt-4o, claude-sonnet-4-5, grok-4.3, grok-4.7, google/gemini-2.5-flash (OpenRouter). Bigger models cost you more tokens."
          },
          "structuredOutput": {
            "title": "Strict structured output (xAI)",
            "type": "boolean",
            "description": "xAI/Grok only: send your schema as a strict JSON-schema response format so the model's answer is constrained to it. Falls back automatically to JSON mode + validation if xAI rejects a schema feature. Every answer is validated either way.",
            "default": true
          },
          "maxInputTokens": {
            "title": "Max page tokens sent to the model",
            "minimum": 500,
            "maximum": 400000,
            "type": "integer",
            "description": "Long pages are cut to this many tokens (about 4 characters each) to cap your AI cost. Rows show truncated=true when a page was cut.",
            "default": 12000
          },
          "maxOutputTokens": {
            "title": "Max output tokens",
            "minimum": 100,
            "maximum": 64000,
            "type": "integer",
            "description": "Upper limit for the model's answer. Raise it for very long lists with \"Extract ALL matching items\".",
            "default": 4000
          },
          "crawlDepth": {
            "title": "Crawl depth",
            "minimum": 0,
            "maximum": 1,
            "type": "integer",
            "description": "0 = only the start URLs. 1 = also extract every same-site page linked from the start URLs (up to \"Max pages\"). Login links are skipped.",
            "default": 0
          },
          "maxPages": {
            "title": "Max pages",
            "minimum": 1,
            "maximum": 10000,
            "type": "integer",
            "description": "Hard cap on pages processed in one run (start URLs plus crawled pages). Also bounds your cost.",
            "default": 100
          },
          "concurrency": {
            "title": "Concurrency",
            "minimum": 1,
            "maximum": 25,
            "type": "integer",
            "description": "Pages processed in parallel. Lower it if your AI provider rate-limits you (HTTP 429 is retried automatically).",
            "default": 5
          },
          "contentMode": {
            "title": "Page content sent to the model",
            "enum": [
              "auto",
              "main",
              "full"
            ],
            "type": "string",
            "description": "Auto (default): main content for single pages (strips menus, footers and cookie banners to save tokens) and the full cleaned page when \"Extract ALL matching items\" is on, so no list item is dropped. Main content / Full page force one mode.",
            "default": "auto"
          },
          "includeLinks": {
            "title": "Keep link URLs in the page text",
            "type": "boolean",
            "description": "Turn on if you want the model to extract URLs (product links, apply links). Uses more tokens.",
            "default": false
          },
          "includeMarkdown": {
            "title": "Include the page Markdown in each row",
            "type": "boolean",
            "description": "Adds the exact text sent to the model, handy for checking answers.",
            "default": false
          },
          "pageTimeoutSecs": {
            "title": "Page load timeout (seconds)",
            "minimum": 5,
            "maximum": 120,
            "type": "integer",
            "description": "How long to wait for each web page.",
            "default": 30
          },
          "aiTimeoutSecs": {
            "title": "AI request timeout (seconds)",
            "minimum": 10,
            "maximum": 600,
            "type": "integer",
            "description": "How long to wait for the model's answer (retried once on timeout).",
            "default": 120
          },
          "llmBaseUrl": {
            "title": "Custom API base URL (advanced)",
            "type": "string",
            "description": "Only for OpenAI-compatible gateways or proxies (e.g. https://my-gateway.example.com/v1). Leave empty to use the provider's official API."
          }
        }
      },
      "runsResponseSchema": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "actId": {
                "type": "string"
              },
              "userId": {
                "type": "string"
              },
              "startedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "finishedAt": {
                "type": "string",
                "format": "date-time",
                "example": "2025-01-08T00:00:00.000Z"
              },
              "status": {
                "type": "string",
                "example": "READY"
              },
              "meta": {
                "type": "object",
                "properties": {
                  "origin": {
                    "type": "string",
                    "example": "API"
                  },
                  "userAgent": {
                    "type": "string"
                  }
                }
              },
              "stats": {
                "type": "object",
                "properties": {
                  "inputBodyLen": {
                    "type": "integer",
                    "example": 2000
                  },
                  "rebootCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "restartCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "resurrectCount": {
                    "type": "integer",
                    "example": 0
                  },
                  "computeUnits": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "options": {
                "type": "object",
                "properties": {
                  "build": {
                    "type": "string",
                    "example": "latest"
                  },
                  "timeoutSecs": {
                    "type": "integer",
                    "example": 300
                  },
                  "memoryMbytes": {
                    "type": "integer",
                    "example": 1024
                  },
                  "diskMbytes": {
                    "type": "integer",
                    "example": 2048
                  }
                }
              },
              "buildId": {
                "type": "string"
              },
              "defaultKeyValueStoreId": {
                "type": "string"
              },
              "defaultDatasetId": {
                "type": "string"
              },
              "defaultRequestQueueId": {
                "type": "string"
              },
              "buildNumber": {
                "type": "string",
                "example": "1.0.0"
              },
              "containerUrl": {
                "type": "string"
              },
              "usage": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "integer",
                    "example": 1
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              },
              "usageTotalUsd": {
                "type": "number",
                "example": 0.00005
              },
              "usageUsd": {
                "type": "object",
                "properties": {
                  "ACTOR_COMPUTE_UNITS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATASET_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "KEY_VALUE_STORE_WRITES": {
                    "type": "number",
                    "example": 0.00005
                  },
                  "KEY_VALUE_STORE_LISTS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_READS": {
                    "type": "integer",
                    "example": 0
                  },
                  "REQUEST_QUEUE_WRITES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_INTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "DATA_TRANSFER_EXTERNAL_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_SERPS": {
                    "type": "integer",
                    "example": 0
                  },
                  "PROXY_UNBLOCKER_UNITS": {
                    "type": "integer",
                    "example": 0
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}