Developer guide

Document extraction

Extract the fields you define in a JSON Schema from a PDF, an image or plain text.

Apart from POST /v1/systemone, you can use the extraction API, POST /v1/extract, which is built to extract structured data from PDFs and images. You don’t write the questions yourself: you describe the fields you want, and the API finds each one in the document and returns it in the type you asked for.

Extracting fields from a document

Send a PDF or an image together with a JSON Schema that lists the fields you want. For each field, Strom finds the line in the document that contains it. Scanned pages and images are converted to text using OCR automatically.

Request
curl https://api.uprelic.com/v1/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "strom-1.0.8",
    "schema": {
      "properties": {
        "invoice_number": {"type": "string"},
        "invoice_date": {"type": "string", "format": "date"},
        "total": {"type": "number", "format": "amount", "description": "The total including tax"},
        "paid": {"type": "boolean"}
      }
    },
    "document": {"url": "data:application/pdf;base64,JVBERi0xLjQK..."}
  }'

document.url can be a public URL or a base64 data: URL. PDFs can have at most 8 pages. model can be strom-fast or strom-base (beta), or their versioned names; strom-base is much slower and costs more.

With "model": "strom-extract-1.0.1", a model built only for extraction reads the document instead: each field's text is the document's own words that answer it (06 NOV 2026, not the whole line SHIPPED ON BOARD 06 NOV 2026), and box is around those words together with any words printed right next to them, for example one table cell. It takes text, number, date and list fields (boolean and enum fields get a 422) and costs $0.10 per 1M input tokens (on our test bills of lading it used about a fifth of the tokens). See the extract model.

Extracting fields from plain text

With strom-extract-1.0.1, you can send plain text instead of a file. Put it in document.text in place of document.url:

Request
curl https://api.uprelic.com/v1/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "strom-extract-1.0.1",
    "schema": {
      "properties": {
        "invoice_number": {"type": "string"},
        "invoice_date": {"type": "string", "format": "date"},
        "total": {"type": "number", "description": "The total including tax"}
      }
    },
    "document": {"text": "ACME GmbH\nInvoice no. 17795\nDate: 16 Dec 2026\nTotal EUR 428.40"}
  }'

A text has no pages, so each field's page and box are null. Instead, start and end say where the field's text is in your text: start is the position of its first character and end the position after its last, counted in Unicode characters from 0. So document.text[start:end] in Python is exactly the field's text. For the request above:

Response · illustrative
"invoice_number": {
  "text": "17795", "value": "17795", "confidence": 0.97,
  "page": null, "box": null, "start": 22, "end": 27
}

JavaScript counts some characters, such as emoji, as two, so in JavaScript each such character moves the positions after it by one. A text can have at most 400,000 characters. With strom-fast or strom-base, a text gets a 422.

Each field can have a description. Use it to tell the model what to look for when the name alone is ambiguous, for example whether total includes tax.

API Response

For each field, the response contains:

  • text: the line of the document the field was found on, exactly as it appears.
  • value: that line converted to the field’s type, for example a date as 1988-12-16 or an amount as 14982.0. See the table below.
  • confidence: how sure the model is that it picked the right line, from 0 to 1.
  • page and box: where the line is. box is [left, top, right, bottom] as fractions of the page’s width and height.
  • start and end: for a text document, where text is in it (see above); null for files.

If the document doesn’t contain a field, that field is null.

Response · illustrative
{
  "model": "strom-1.0.8",
  "fields": {
    "invoice_number": {
      "text": "17795", "value": "17795", "confidence": 0.98,
      "page": 1, "box": [0.7731, 0.1286, 0.8225, 0.1424]
    },
    "invoice_date": {
      "text": "12/16/88", "value": "1988-12-16", "confidence": 0.94,
      "page": 1, "box": [0.7731, 0.1552, 0.85, 0.1705]
    },
    "total": {
      "text": "$14,982.00", "value": 14982.0, "confidence": 0.55,
      "page": 1, "box": [0.8306, 0.3529, 0.9256, 0.3662]
    },
    "paid": {"text": null, "value": false, "confidence": 0.58, "page": null, "box": null}
  },
  "usage": {
    "input_tokens": 20060, "output_tokens": 5, "cached_input_tokens": 25344,
    "cost": 0.00084252, "currency": "usd"
  },
  "metadata": {"server_processing_time_ms": 3405}
}

Field types

The field’s type and format in the schema decide how text is converted into value, and which models take the field:

Type, format Line in the document value strom-fast, strom-base strom-extract
"string" Invoice no. 17795 "Invoice no. 17795" ✓ ✓
"string", "date" Date: 12/16/88 "1988-12-16" ✓ ✓
"number" Quantity 12 12 ✓ ✓
"number", "amount" Total EUR 1.234,50 1234.5 ✓ ✓
"number", "percent" VAT 19% 19 ✓ ✓
"boolean" (answered without a line) true or false ✓ ✗
"enum" (answered without a line) "EUR" ✓ ✗
"array" of strings or numbers IBAN DE89 3704 … one item per match ✗ ✓
"array" of objects A table of line items one item per row ✗ ✓

If the line contains more than one date, number or percentage, we don’t guess which one you meant: value is then the whole line, the same as text. A field type a model doesn’t take gets a 422.

List fields

With strom-extract-1.0.1, a field can be a list: every IBAN in a document, or the rows of a table such as an invoice’s line items. Give it "type": "array" and say what each item is in items:

  • A list of single values: items is a string or number type, with a format if you like.
  • A table: items is an object whose properties are the table’s columns, each a string or number type.
Request
curl https://api.uprelic.com/v1/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "strom-extract-1.0.1",
    "schema": {
      "properties": {
        "ibans": {"type": "array", "items": {"type": "string"}, "description": "Every IBAN"},
        "line_items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "description": {"type": "string"},
              "quantity": {"type": "number"},
              "amount": {"type": "number", "format": "amount"}
            }
          }
        }
      }
    },
    "document": {"url": "data:application/pdf;base64,JVBERi0xLjQK..."}
  }'

A list field’s answer has a confidence for the whole list and its items, in the order they appear in the document:

  • In a list of single values, each item has text, value and its position, like a field, but no confidence of its own.
  • In a table, each item is one row, with an answer for each column. Every answer in a column has the same confidence: the model’s confidence that it found the right column. A column that’s empty in a row is null.

If the document has no such list, the field is null.

Response · illustrative
"ibans": {
  "confidence": 0.97,
  "items": [
    {"text": "DE89 3704 0044 0532 0130 00", "value": "DE89 3704 0044 0532 0130 00",
     "page": 1, "box": [0.0945, 0.7112, 0.4806, 0.7275]},
    {"text": "DE12 5001 0517 0648 4898 90", "value": "DE12 5001 0517 0648 4898 90",
     "page": 1, "box": [0.0945, 0.7331, 0.4806, 0.7494]}
  ]
},
"line_items": {
  "confidence": 0.91,
  "items": [
    {
      "description": {"text": "Consulting November", "value": "Consulting November", "confidence": 0.95,
                      "page": 1, "box": [0.0923, 0.4512, 0.3105, 0.4676]},
      "quantity": {"text": "10", "value": 10, "confidence": 0.91,
                   "page": 1, "box": [0.5302, 0.4512, 0.5491, 0.4676]},
      "amount": {"text": "950.00 EUR", "value": 950.0, "confidence": 0.93,
                 "page": 1, "box": [0.7801, 0.4512, 0.9008, 0.4676]}
    },
    {
      "description": {"text": "Training", "value": "Training", "confidence": 0.95,
                      "page": 1, "box": [0.0923, 0.4731, 0.1987, 0.4895]},
      "quantity": null,
      "amount": {"text": "1,200.00 EUR", "value": 1200.0, "confidence": 0.93,
                 "page": 1, "box": [0.7708, 0.4731, 0.9008, 0.4895]}
    }
  ]
}

A column’s description helps the model tell similar columns apart, for example a unit price from a line total. Each column counts toward the 256 fields a schema can have.

Cost and errors

  • You pay for input tokens at the same price as POST /v1/systemone. The cost of each extraction is in usage.cost. For example, a 2-page PDF invoice with a 10-field schema used about 28,000 input tokens.
  • The “Improve document extraction” switch under Billing comes with the paid plans and works with every model; list fields and documents sent as plain text aren't used yet. Each run that improves your extraction is charged to your balance, about €2 to €3 a run.
  • We keep the document you send, with your request and the extracted fields, for as long as your plan keeps request contents (7 days on Free), then delete it. You can download it with your data export.
  • For sensitive documents, send the same request to POST /v1/extract/private. We keep no document, schema or extracted fields from it, and input tokens cost 20% more. See Zero data retention.
  • Documents that can’t be read are not charged. You get a 422 with the reason in detail, for example when the file isn’t a PDF or image, has no text, or has more than 8 pages.