Schema-driven structured extraction

Fetches `url` and extracts structured JSON conforming to the supplied JSON Schema (draft 2020-12) using an LLM. Fast-path only — slow-path rendering options (`wait_until=networkidle`, `cookies`, `delay_ms`, custom `headers`, `wait_for_selector`) cause a `400 unsupported_url`. Dual-axis billing: a fixed per-request credit charge **plus** the underlying page's bandwidth, billed exactly like `/v1/scrape`. The bandwidth is still billed when the scrape succeeds but extraction later fails; both axes are refunded only when the scrape itself never runs. Availability is gated by a server-side feature flag; when disabled the endpoint returns `404`.

POST
/v1/schema

Authorization

AuthorizationRequiredBearer <token>

API key. Manage keys from the dashboard at app.bytekit.com.

In: header

Request Body

application/jsonRequired
urlRequiredstring

Target page URL (HTTP/HTTPS, SSRF-blocked, fast-path only).

Format: "uri"
schemaRequiredobject

JSON Schema (draft 2020-12) describing the desired output. Serialized size ≤ 50 KB, nesting depth ≤ 8, must compile under Ajv, and must be normalizable into Groq's strict-mode subset (root type: object; no pattern/format/if/then/else/ top-level oneOf/anyOf; $ref limited to #/$defs). A non-normalizable schema returns 422 schema_incompatible.

promptstring

Optional natural-language extraction hint.

Maximum length: 2000
modelstring

Extraction model. An out-of-list value returns 400 unsupported_model (not a Zod 422).

Default: "openai/gpt-oss-20b"Value in: "openai/gpt-oss-20b" | "openai/gpt-oss-120b"
wait_for_selectorstring | null
Default: null
wait_untilstring
Default: "load"Value in: "load" | "domcontentloaded" | "networkidle"
cookiesarray<object>
Default: []
delay_msinteger
Default: 0Minimum: 0Maximum: 10000
headersobject
Default: {}
countrystring | null

Two-letter country code, upper-cased. null is coerced to US.

Default: "US"
languagestring | null
Default: null
curl -X POST https://api.bytekit.com \
  -H "Authorization: Bearer sk_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://stripe.com/pricing","schema":{"type":"object","properties":{"plan_name":{"type":"string"},"monthly_price_usd":{"type":"number"}}},"prompt":"Extract the cheapest paid plan.","model":"openai/gpt-oss-20b"}'

Extraction completed (success or graceful extract failure).

{
  "data": {},
  "model": "string",
  "validated": true,
  "metrics": {
    "scrape_ms": 0,
    "llm_total_ms": 0,
    "input_tokens": 0,
    "output_tokens": 0,
    "retries": 0,
    "total_ms": 0
  },
  "scrape": {
    "url": "http://example.com",
    "status_code": 0,
    "content_length": 0,
    "truncated": true
  },
  "warnings": [
    "string"
  ]
}