Document extraction
POST /v1/extractPOST /v1/extract/batchPOST /v1/extract/jobsfrom $0.80 / 1M tokensSend a template (the shape of the answer, with a type for each field) and a document as text, an image, or both. You get the template filled in, plus a confidence between 0 and 1 for every field.
It is built for African and English everyday documents: mobile-money and bank messages, receipts and bills in African currencies, letters, notices and forms. Powered by MIST-Extract-1.0 and MIST-Extract-Flash-1.0.
Example
Section titled “Example”r = call("/v1/extract", { "template": {"recipient": "verbatim-string", "amount": "number", "fee": "number", "reference": "verbatim-string", "date": "date"}, "text": "Your MTN MoMo transfer of GHS 250.00 to KOFI MENSAH was successful. " "Fee GHS 2.50. Ref 88213374. 14/10/2025", "instructions": "Dates in this message are day/month/year."})print(r["data"], r["confidence"])curl -X POST "$OLAVERSE_URL/v1/extract" \ -H "Authorization: Bearer $OLAVERSE_KEY" -H "Content-Type: application/json" \ -d '{"template": {"recipient": "verbatim-string", "amount": "number", "date": "date"}, "text": "Your MTN MoMo transfer of GHS 250.00 to KOFI MENSAH was successful. 14/10/2025", "instructions": "Dates in this message are day/month/year."}'{"model": "mist-extract-1.0", "data": {"recipient": "KOFI MENSAH", "amount": 250, "fee": 2.5, "reference": "88213374", "date": "2025-10-14"}, "confidence": {"recipient": 0.9785, "amount": 0.9932, "fee": 0.9971, "reference": 0.985, "date": 0.9897}, "usage": {"input_tokens": 214, "output_tokens": 38, "documents": 1}}From a photo or screenshot
Section titled “From a photo or screenshot”Send the image as base64 or a data URL. Image links are not fetched.
import base64img = base64.b64encode(open("receipt.jpg", "rb").read()).decode()r = call("/v1/extract", { "template": {"total": "number", "items": [{"name": "verbatim-string", "price": "number"}]}, "image": "data:image/jpeg;base64," + img})Request
Section titled “Request”| Field | Default | Notes |
|---|---|---|
template |
required | A JSON object (or a JSON string) with the shape of the answer, up to 24,000 characters. |
text |
The document as text, up to 120,000 characters (longer: use a job). Give text, image or both. |
|
image |
One JPEG or PNG as base64 or a data URL, up to 10 MB. Large photos are scaled down automatically. | |
instructions |
Optional guidance, such as “Dates are day/month/year” or “amounts in kobo”. | |
model |
mist-extract-1.0 |
mist-extract-1.0, the only extraction model on the API. mist-extract-flash-1.0 is still accepted and runs mist-extract-1.0. |
Template types
Section titled “Template types”Each leaf of the template names the type of that field:
| Type | Meaning |
|---|---|
"verbatim-string" |
Copied exactly from the document |
"string" |
Free text; may be tidied or paraphrased |
"number", "integer" |
Plain numbers, no currency symbols or separators |
"date" |
ISO YYYY-MM-DD |
"date-time" |
ISO date and time |
"boolean" |
true or false |
["cash", "card"] |
Pick one option |
[["cash", "card"]] |
Pick any number of options |
["string"] |
A list of values |
[{...}] |
A list of objects, such as line items |
A missing value comes back as null, and an empty list as [].
Using the confidence
Section titled “Using the confidence”Confidence is calibrated: when a field says 0.66, it is right about 66% of the time. A common pattern is to accept fields at 0.95 or above automatically and send the rest to a person to check. An empty list has no confidence.
How well that holds depends on how close your documents are to the ones the model was calibrated on: English and African-language everyday documents (receipts, mobile-money and bank messages, bills, letters and forms). Before you automate on a threshold, check it on a sample of your own documents: extract 100 to 200 you have the right answers for, and look at how often fields at or above your threshold are actually right. If they’re right less often than the threshold says, raise it.
Calibrated on your documents (enterprise)
Section titled “Calibrated on your documents (enterprise)”For production volumes, we can calibrate the confidence on your documents, so that 0.95 means right 95% of the time on the documents you actually send, in whatever language or format they are.
- You send 50 to 2,000 of your documents with the right answers, in the template you’ll use.
- We extract them, fit a calibration on half the fields and measure it on the other half. You get the before-and-after report (calibration error and how often fields in each confidence band were right) before anything changes.
- Once you approve it, every extraction on your account (single calls, batches and jobs) uses it, and the response includes
"calibration": "custom"so you can tell.
Calibration makes the confidence trustworthy on your documents. It doesn’t change the extracted values themselves; for that, ask about fine-tuning on your data. Get in touch to set it up.
POST /v1/extract/batch takes up to 16 documents:
{"model": "mist-extract-1.0", "documents": [{"id": "a", "template": {...}, "text": "..."}, {"id": "b", "template": {...}, "image": "data:image/png;base64,..."}]}Each document succeeds or fails on its own. An invalid document comes back with "error" and "status": 400 in its place, and only extracted documents are billed:
{"model": "mist-extract-1.0", "results": [{"id": "a", "data": {...}, "confidence": {...}}, {"id": "b", "data": null, "confidence": null, "error": "give the document as 'text', 'image' ...", "status": 400}], "usage": {"input_tokens": 230, "output_tokens": 41, "documents": 1}}Long documents
Section titled “Long documents”For contracts, filings, statements and reports over 120,000 characters, create a job: POST /v1/extract/jobs takes the whole document, up to 3,000,000 characters of text or 200 page images in pages. It splits the document into parts at page breaks (form feeds, \f, if your text has them) or paragraph boundaries (or one part per page image), extracts every part in parallel with the same template, and merges the answers. Lists are joined in document order (a row repeated on every page, such as a heading list, is kept once), and for single values the most confident part wins.
Creating the job is free and returns 202 at once. Poll it until status is no longer running:
import os, time, requests
BASE = "https://api.olaverselab.com"HEADERS = {"Authorization": f"Bearer {os.environ['OLAVERSE_KEY']}"}
job = requests.post(f"{BASE}/v1/extract/jobs", headers=HEADERS, json={ "template": {"issuer": "verbatim-string", "holdings": [{"name": "verbatim-string", "value": "number"}]}, "text": open("filing.txt").read(), "instructions": "holdings come from the information table, not the cover page"}).json()# {"id": "exj_...", "status": "running", "parts": 8, "poll": "/v1/extract/jobs/exj_..."}
while (r := requests.get(f"{BASE}{job['poll']}", headers=HEADERS).json())["status"] == "running": time.sleep(5) # r["parts_done"] shows progressprint(r["data"], r["usage"]){"id": "exj_6d1c...", "model": "mist-extract-1.0", "status": "completed", "parts": 8, "parts_done": 8, "data": {...}, "confidence": {...}, "failed_parts": [], "usage": {"input_tokens": 61204, "output_tokens": 3311, "documents": 1, "parts": 8}}- Estimate. The
202reply includes"estimate": {"cost_usd": ..., "seconds": ...}, a cautious estimate of the job’s cost and time. If your credit can’t cover the estimate, you get402and nothing runs; add credit or send fewer pages. - Size. A job can take up to 300 parts (roughly a few hundred pages). Bigger documents get
413: send them in sections. - Durable. A job survives restarts on our side: finished parts are saved as it goes, and an interrupted job resumes on its own.
- Fair share. Each account runs a limited number of parts at once, so very large jobs take longer, and other calls stay fast.
- Billing. You pay for the tokens of the parts that were extracted, once, the first time you read the completed result. Creating the job, polling it and reading it again are free, and a failed job isn’t billed.
- Parts that fail are listed in
failed_partsand not billed. The job fails only if no part could be extracted. - Privacy. A job can only be read with an API key on the account that created it. Results are deleted 7 days after the job finishes, and the document itself is never stored.
- Fields that span parts. Each part sees only its own text, so ask for a value that needs the whole document (a grand total, say) from the page that states it.
Pricing
Section titled “Pricing”Extraction is charged per token, like the rest of the token-priced models: $0.80 in · $4.00 out per 1M tokens.
- Input tokens are the template, any instructions and the document. A page of English text is about 1,000 tokens (one word is about 1.3 tokens). An image token is a 32 × 32 pixel patch, and images are scaled to about 1.3 megapixels, so a photo or A4 scan is at most about 1,300 tokens.
- Output tokens are the JSON the model writes, typically 50 to 300 for a receipt or a payment message.
- A one-page text receipt costs about $0.0015 and a photo of an A4 page about $0.002. Each request is charged for at least 500 input tokens, and documents that fail or come back as invalid JSON are not charged.
usage in every response shows the tokens you were charged for.
About 1 second per document. Long documents and large batches take longer, so give your HTTP client a timeout of about 2 minutes. A job takes about 10 to 60 seconds for a 50 to 100 page document.