Why did we open-source our inference engine? Read the post

More document fields right than Claude Sonnet 5.5, for 88% less

Pull the fields you need out of checks, invoices, statements and forms as typed JSON that fits your schema. SIE runs Gemma 4 31B, an open vision model: send a page image, get the record back.

SIE Gemma 4 31B

Specs match the note
Delivery note, item 1
Delivery note line item 1 description: rated power output 662W continuous; 220-240v input, 24v DC output; power factor correction 0.98, efficiency rating 91%; recessed mounting design; compact steel enclosure, weight 1.4kg; IP65 protection class.
items[0].productSpecsJson
{
  "power": {
    "watts": 662, "efficiency": 91,
    "powerFactor": 0.98, "inputVoltage": "220-240v"
  },
  "ratings": { "protection": "ip65" },
  "physical": {
    "weight": 1.4, "material": "steel",
    "mountingType": "recessed"
  }
}
Delivery note, item 1
Delivery note line item 1: rated power output 662W continuous; 220-240v input, 24v DC output; power factor correction 0.98, efficiency rating 91%.
items[0].productSpecsJson.power
{
  "watts": 662,
  "efficiency": 91,
  "powerFactor": 0.98,
  "inputVoltage": "220-240v"
}

Frontier APIs misread fields and reject large schemas

Bank check, scanned sideways
Bank check scanned sideways: Aliyah Zemlak, 6537 Maybell Station, Rennerport, Tennessee; pay to Gorczany - Gusikowski $7,069.68; bank-code line routing number 99263305, account 5124254359, check number 8535.

GPT-6.1 Sol, reasoning xhigh

11 of 15 fields right
{
  "checkNumber": 535,
  "routingNumber": 799263305,
  "address": "6537 Moylett Station",
  "city": "Rempelport"
}

SIE Gemma 4 31B

15 of 15 fields right
{
  "checkNumber": 8535,
  "routingNumber": 99263305,
  "address": "6537 Maybell Station",
  "city": "Rennerport"
}

Claude Sonnet 5.5 and Claude Haiku 5.5

82 of 546 schemas rejected
400 invalid_request_error: Schemas contains too many optional parameters (42), which would make grammar compilation inefficient. Reduce the number of optional parameters in your tool schemas (limit: 24).

61 for too many optional fields, 21 as "Schema is too complex."

SIE Gemma 4 31B

546 of 546 schemas accepted

Every schema went in unchanged, as the strict response format, and came back as typed fields.

98% of GPT-6.1 Sol's accuracy, for 85% less

Accuracy against cost
546 business documents in 17 formats
Fields read correctly ↑ Cost per 1,000 documents →
Share of answer-key fields each model read correctly on 546 business documents, against its list-price cost per 1,000 documents
ModelFields read correctlyCost per 1,000 documents
GPT-6.1 Sol96.1%$14.63
SIE Gemma 4 31B94.3%$2.11
GPT-6 Luna, high92.3%$1.12
Claude Sonnet 5.592.2%$18.68
Claude Haiku 5.588.2%$1.19
Mistral OCR 4.183.4%$9.00
Field accuracy evaluation

546 business documents in 17 formats

Documents
OmniAI OCR Benchmark: checks, invoices, statements, forms
Scoring
Answer-key fields returned exactly; failed or cut-off replies score zero
Settings
Each API at its default or a stronger setting, every model with 8,192 output tokens
Prices
Real-time list prices on each model's own recorded tokens; Gemma 4 31B at its Serverless rate

Send a page and your schema, get typed fields back

from pathlib import Path
import base64
import json
from sie_sdk import SIEClient
​
client = SIEClient(api_key="API keysk-sie-…")
​
schema = json.loads("""
schema{
"type": "object",
"properties": {
"items": {"anyOf": [{"type": "array", "items": {"type": "object", "properties": {···"brand": ···, "quantity": ···, "reference": ···, "productSpecsJson": {···"watts": ···, "efficiency": ···}, {"type": "null"}]},
"header": {"type": "object", "properties": {···"date": ···}
},
"required": ["items", "header"],
"additionalProperties": false
}
""")
instruction = "instruction···Copy values as they appear on the document.···"
prompt = f"{instruction}\n\nJSON schema:\n{json.dumps(schema, indent=2, ensure_ascii=False)}"
image = base64.b64encode(Path(fileJPGdelivery-note.jpgbrowse).read_bytes()).decode("ascii")
# Messages: the prompt as the system message, the image as the user message. Copy includes them.
result = client.chat_completions(
"modelgoogle/gemma-4-31B-it:h100-96k-hires-out8k-no-spec",
messages,
max_completion_tokens=8192,
extra_body={"temperature":0,"presence_penalty":0},
# Strict JSON-schema response_format. Copy includes it.
)
# Copy also reads and parses the JSON reply.
import { readFile } from 'node:fs/promises';
import { SIEClient } from '@superlinked/sie-sdk';

const client = new SIEClient(undefined, { apiKey: 'sk-sie-…' });

const schema = {
  "type": "object",
  "properties": {
    "items": {"anyOf": [{"type": "array", "items": {"type": "object", "properties": {···"brand": ···, "quantity": ···, "reference": ···, "productSpecsJson": {···"watts": ···, "efficiency": ···}, {"type": "null"}]},
    "header": {"type": "object", "properties": {···"date": ···}
  },
  "required": ["items", "header"],
  "additionalProperties": false
};
const instruction = "···Copy values as they appear on the document.···";
const prompt = `${instruction}\n\nJSON schema:\n${JSON.stringify(schema, null, 2)}`;
const image = await readFile("delivery-note.jpg");
const result = await client.chatCompletions({
  model: 'google/gemma-4-31B-it:h100-96k-hires-out8k-no-spec',
  // Messages: the prompt as the system message, the image as the user message. Copy includes them.
  max_completion_tokens: 8192,
  temperature: 0,
  presence_penalty: 0,
  // Strict JSON-schema response_format. Copy includes it.
});
// Copy also reads and parses the JSON reply.
document_image=$(base64 < 'delivery-note.jpg' | tr -d '\n')
curl https://api.superlinked.com/v1/chat/completions \
  -H "Authorization: Bearer sk-sie-…" \
  -H "Content-Type: application/json" \
  -d "{\"model\":\"google/gemma-4-31B-it:h100-96k-hires-out8k-no-spec\",\"messages\":[{\"role\":\"system\",\"content\":\"···Copy values as they appear on the document.···\\n\\nJSON schema:\\n{\\n  \\\"type\\\": \\\"object\\\",\\n  \\\"properties\\\": {\\n    \\\"items\\\": {\\\"anyOf\\\": [{\\\"type\\\": \\\"array\\\", \\\"items\\\": {\\\"type\\\": \\\"object\\\", \\\"properties\\\": {···\\\"brand\\\": ···, \\\"quantity\\\": ···, \\\"reference\\\": ···, \\\"productSpecsJson\\\": {···\\\"watts\\\": ···, \\\"efficiency\\\": ···}, {\\\"type\\\": \\\"null\\\"}]},\\n    \\\"header\\\": {\\\"type\\\": \\\"object\\\", \\\"properties\\\": {···\\\"date\\\": ···}\\n  },\\n  \\\"required\\\": [\\\"items\\\", \\\"header\\\"],\\n  \\\"additionalProperties\\\": false\\n}\"},{\"role\":\"user\",\"content\":[{\"type\":\"image_url\",\"image_url\":{\"url\":\"data:image/jpeg;base64,$document_image\"}}]}],\"max_completion_tokens\":8192,\"temperature\":0,\"presence_penalty\":0,\"response_format\":{\"type\":\"json_schema\",\"json_schema\":{\"name\":\"fields\",\"strict\":true,\"schema\":{\"type\":\"object\",\"properties\":{\"items\":{\"anyOf\":[{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"sn\":{\"anyOf\":[{\"type\":\"number\"},{\"type\":\"null\"}]},\"type\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"LED Luminaire\",\"Power Supply\",\"Control System\",\"Mounting Bracket\",\"LED Driver\",\"Cable Assembly\",\"Junction Box\",\"Sensor Module\"]},{\"type\":\"null\"}]},\"unit\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"pcs\",\"set\",\"unit\"]},{\"type\":\"null\"}]},\"brand\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"Philips\",\"Osram\",\"Schneider Electric\",\"Siemens\",\"ABB\",\"Lutron\",\"Legrand\",\"Mean Well\"]},{\"type\":\"null\"}]},\"quantity\":{\"anyOf\":[{\"type\":\"number\"},{\"type\":\"null\"}]},\"reference\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"productSpecsJson\":{\"type\":\"object\",\"properties\":{\"power\":{\"type\":\"object\",\"properties\":{\"watts\":{\"anyOf\":[{\"type\":\"number\"},{\"type\":\"null\"}]},\"efficiency\":{\"anyOf\":[{\"description\":\"Efficiency in percentage, 0-100\",\"type\":\"number\"},{\"type\":\"null\"}]},\"powerFactor\":{\"anyOf\":[{\"type\":\"number\"},{\"type\":\"null\"}]},\"inputVoltage\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"100-240v\",\"100-277v\",\"220-240v\"]},{\"type\":\"null\"}]}},\"required\":[\"watts\",\"efficiency\",\"powerFactor\",\"inputVoltage\"],\"additionalProperties\":false},\"ratings\":{\"type\":\"object\",\"properties\":{\"protection\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"ip65\",\"ip66\",\"ip67\"]},{\"type\":\"null\"}]}},\"required\":[\"protection\"],\"additionalProperties\":false},\"physical\":{\"type\":\"object\",\"properties\":{\"weight\":{\"anyOf\":[{\"type\":\"number\"},{\"type\":\"null\"}]},\"material\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"aluminum\",\"steel\",\"plastic\"]},{\"type\":\"null\"}]},\"mountingType\":{\"anyOf\":[{\"type\":\"string\",\"enum\":[\"surface\",\"recessed\",\"track\"]},{\"type\":\"null\"}]}},\"required\":[\"weight\",\"material\",\"mountingType\"],\"additionalProperties\":false}},\"required\":[\"power\",\"ratings\",\"physical\"],\"additionalProperties\":false}},\"required\":[\"sn\",\"type\",\"unit\",\"brand\",\"quantity\",\"reference\",\"productSpecsJson\"],\"additionalProperties\":false}},{\"type\":\"null\"}]},\"header\":{\"type\":\"object\",\"properties\":{\"to\":{\"type\":\"object\",\"properties\":{\"tel\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"email\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"location\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"attention\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"reference\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"vatNumber\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"companyName\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]}},\"required\":[\"tel\",\"email\",\"location\",\"attention\",\"reference\",\"vatNumber\",\"companyName\"],\"additionalProperties\":false},\"date\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"from\":{\"type\":\"object\",\"properties\":{\"tel\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"email\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"location\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"reference\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"vatNumber\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]},\"companyName\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]}},\"required\":[\"tel\",\"email\",\"location\",\"reference\",\"vatNumber\",\"companyName\"],\"additionalProperties\":false},\"projectName\":{\"anyOf\":[{\"type\":\"string\"},{\"type\":\"null\"}]}},\"required\":[\"to\",\"date\",\"from\",\"projectName\"],\"additionalProperties\":false}},\"required\":[\"items\",\"header\"],\"additionalProperties\":false}}}}"
Build the "Doc field extraction" capability into my app using the Superlinked Inference Engine (SIE).

Context
- SIE is an OpenAI-style inference API. Python SDK: `from sie_sdk import SIEClient`; TypeScript: `@superlinked/sie-sdk`.
- Base URL: https://api.superlinked.com (or my regional endpoint). Auth: Bearer key from env `SIE_API_KEY` (never hard-code it).
- Model: google/gemma-4-31B-it:h100-96k-hires-out8k-no-spec (OpenAI-compatible endpoint: /v1/chat/completions). Keep the model id configurable.

Task
- Input: an uploaded document plus the JSON schema for its fields.
- Behaviour: parse the document, then return fields matching the JSON schema
- Send one POST /v1/chat/completions request (SDK: chat_completions / chatCompletions) with a system message and a user message. The system message is "Extract data from the document image into the JSON schema. Copy values as they appear on the document. Use null for a field the document does not contain. Return only the JSON.", a blank line, "JSON schema:" and the submitted schema as JSON indented by two spaces; response_format only constrains decoding, so the model reads the field descriptions from this text. The user message holds only an image_url part. Base64-encode the original local image bytes as a canonical data:image/png, data:image/jpeg or data:image/webp URI (normalize jpg to image/jpeg). Use max_completion_tokens 8192, temperature 0 and response_format {type: "json_schema", json_schema: {name: "fields", strict: true, schema}} with the submitted schema unchanged. Parse choices[0].message.content as JSON and fail loudly when it is missing or invalid.

Deliverables
- A typed client wrapper, an application-level function for this task, error handling for timeouts/empty input, and unit tests with a stubbed client.
- Wire it into my existing stack (ask me which framework if unclear) and add a short usage example.
Output

deliveryDate 2025-02-12

items
referencebrandquantitywattsefficiency
ASDZPDI5YLLutron5010395
FL5GMWQOUQOsram518893
delivery-note.jpg
The delivery note sent with this request: 2 line items with their reference, brand, quantity and description.

Read your documents into your schema

Self-hosted (Kubernetes)

SIE in your clusters, backed by our engineers.

  • Data stays in your own cloud account
  • Same models and API as Serverless
  • Terraform to your cloud in minutes

Run locally

The open-source server on your own machine.

docker run --gpus all -p 8080:8080 ghcr.io/superlinked/sie-server:latest-cuda13-sglang-cu130

Switch to SIE in 5 minutes

from openai import OpenAI
client = OpenAI()
fields = client.chat.completions.create(
    model="gpt-6.1-sol",
    messages=[
        {"role": "system", "content": instruction},
        {"role": "user", "content": [{"type": "image_url",
            "image_url": {"url": f"data:image/png;base64,{page_b64}"}}]},
    ],
    response_format={"type": "json_schema", "json_schema": {
        "name": "fields", "schema": schema, "strict": True}},
).choices[0].message.content
from anthropic import Anthropic
client = Anthropic()
fields = client.messages.create(
    model="claude-sonnet-5-5",
    system=instruction,
    messages=[{"role": "user", "content": [{"type": "image", "source": {
        "type": "base64", "media_type": "image/png", "data": page_b64}}]}],
    output_config={"format": {"type": "json_schema", "schema": schema}},
    max_tokens=8192,
).content[0].text
SIE
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.superlinked.com/v1", api_key=SIE_API_KEY)
fields = client.chat.completions.create(
    model="google/gemma-4-31B-it:h100-96k-hires-out8k-no-spec",
    messages=[
        {"role": "system", "content": f"{instruction}\n\nJSON schema:\n{json.dumps(schema)}"},
        {"role": "user", "content": [{"type": "image_url",
            "image_url": {"url": f"data:image/png;base64,{page_b64}"}}]},
    ],
    response_format={"type": "json_schema", "json_schema": {
        "name": "fields", "schema": schema, "strict": True}},
).choices[0].message.content
import json
from openai import OpenAI
client = OpenAI(base_url="https://api.superlinked.com/v1", api_key=SIE_API_KEY)
fields = client.chat.completions.create(
    model="google/gemma-4-31B-it:h100-96k-hires-out8k-no-spec",
    messages=[
        {"role": "system", "content": f"{instruction}\n\nJSON schema:\n{json.dumps(schema)}"},
        {"role": "user", "content": [{"type": "image_url",
            "image_url": {"url": f"data:image/png;base64,{page_b64}"}}]},
    ],
    response_format={"type": "json_schema", "json_schema": {
        "name": "fields", "schema": schema, "strict": True}},
).choices[0].message.content

Contact us

Tell us about your use case and we'll get back to you shortly.

Apply for an inference grant

Free capacity on our hosted cluster for selected projects. Tell us what you run and we reply by email.