Skip to content

Use from your app

qaechi-parser is a Python engine. Python apps import it. Apps in other languages run it as a service and call its HTTP API. Both return the same JSON: every value with its quote and page.

Runnable samples for every language live in qaechi/qaechi-examples, and CI runs each of them against a real qaechi-parser on every change.

Pick a way

  • Library, in your process


    import qaechi.parser and call parse(). No server, no token, no network hop.

    Use when your app is Python: scripts, notebooks, FastAPI or Django back ends, batch jobs.

    Python samples

  • Service, over HTTP


    Run qaechi-parser next to your app and call POST /jobs. Jobs run in the background.

    Use when your app is Node.js, TypeScript, Java or anything else, when documents are large, or when several apps share one parser.

    HTTP samples

Declare the dependency

# pyproject.toml
[project]
dependencies = [
  "qaechi-parser[parse]>=2.3,<3",
]

Or pip install "qaechi-parser[parse]". Extras: parse (PDF, PPTX, XLSX), llm (model-based extraction), all.

Your app depends on the service. Run it next to your app:

# docker-compose.yml
services:
  qaechi-parser:
    build: https://github.com/qaechi/qaechi-parser.git#qaechi-parser-v2.3.0
    environment:
      QAECHI_INTERNAL_TOKEN: ${QAECHI_INTERNAL_TOKEN}
      QAECHI_SOURCE_DIR: /data
    volumes: ["./documents:/data:ro"]
    ports: ["127.0.0.1:3100:3100"]

No npm package is needed: Node 20+ has fetch. Copy the small client from the Node.js or TypeScript sample.

Run the service with the same compose snippet, then add Spring Web MVC (it brings RestClient and Jackson):

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>

Copy the qaechi package from the Spring Boot sample.

Always pin a release tag. main can change between releases.

Call it

import qaechi.parser as qp

result = qp.parse("ledger.csv", "ledger", lines=True)
for line in result.lines:
    print(line.label, line.amount.value, line.amount.provenance.quote)
import { createQaechiClient } from "./qaechiClient.js";

const qaechi = createQaechiClient({ baseUrl: process.env.QAECHI_PARSER_URL, token: process.env.QAECHI_INTERNAL_TOKEN });
const result = await qaechi.extract({ source: "ledger.csv", docType: "ledger", lines: true });
import { QaechiParserClient } from "./client.js";

const result = await new QaechiParserClient().extract({ source: "ledger.csv", docType: "ledger", lines: true });
result.total?.value;   // 1225000
Extraction result = parserClient.extract("ledger.csv", "ledger", true, List.of());
result.total().provenance().quote();   // "Total |  | 1225000"
curl -s -X POST http://127.0.0.1:3100/jobs \
  -H "X-Internal-Token: $QAECHI_INTERNAL_TOKEN" -H "Content-Type: application/json" \
  -d '{"documentId":"ledger-2026-11","source":"ledger.csv","docType":"ledger","lines":true}'
# -> {"jobId":"...","status":"queued",...}   then poll GET /jobs/{jobId}

Through the service, one extract call does three requests:

sequenceDiagram
  participant App as Your app
  participant Q as qaechi-parser service
  App->>Q: POST /jobs {documentId, source, docType, fields, lines}
  Q-->>App: 202 {jobId, status: queued}
  loop until succeeded or failed
    App->>Q: GET /jobs/{jobId}
  end
  App->>Q: GET /results/{resultId}
  Q-->>App: Extraction (values with quote and page)

source is a path relative to the service's QAECHI_SOURCE_DIR, or a key in its object store (QAECHI_SOURCE_URL). The service reads the file itself; you send a name, not bytes. Every call except /health sends the X-Internal-Token header. See the HTTP API for every field.

Read the result

Every value carries its evidence. Click the numbers for what each field means.

{
  "route": "parser", // (1)!
  "groundedness": "yes", // (2)!
  "lines": [
    {
      "label": "Design work",
      "amount": {
        "value": 1200000, // (3)!
        "confidence": 1.0,
        "provenance": { "page": 1, "quote": "Design work | 1 | 1,200,000" } // (4)!
      }
    }
  ],
  "total": {
    "value": 1225000,
    "provenance": { "page": 1, "quote": "Total |  | 1225000" }
  },
  "fields": {
    "fee": { "value": null, "provenance": null } // (5)!
  },
  "quoteCheck": { "checked": 4, "notInSource": [] }, // (6)!
  "notes": [] // (7)!
}
  1. How it was read: parser, llm, or stub (no source or no model configured; every value is null).
  2. A second check on the result: yes, no or unknown. Treat it as a signal, not a guarantee.
  3. Numbers come back as numbers: (5000) becomes -5000, 1,200,000 becomes 1200000.
  4. The exact text the value was read from, and its page. Show it next to the value in your UI.
  5. null means no evidence was found. It is never a guess. Route it to review, do not store it as zero.
  6. Quotes the model gave that are not in the document. Anything listed here needs a human.
  7. What the parser could not read, such as pages with no text (a scan without OCR).

When something goes wrong

You see Why What to do
401 Missing or wrong X-Internal-Token Send the same token the service was started with
500 with "QAECHI_INTERNAL_TOKEN is not set" The service has no token configured Set QAECHI_INTERNAL_TOKEN on the service
422 The request body does not match the schema Check field names (camelCase) and that source and docType are set
404 on /jobs/{id} or /results/{id} Unknown ID, or the service restarted Results live in memory by default; see Before production
Job status: failed The file was missing, unreadable, or a layout did not match Read error on the job; fix the file or the docType
Every value is null, route: stub No source folder or no model configured Set QAECHI_SOURCE_DIR, and a model for free-form documents
Java: 400 or 422 with an empty body The JDK HTTP client asked the server to upgrade to HTTP/2 Build the client with HttpClient.Version.HTTP_1_1, as the sample does
Poll never finishes A large document Keep polling with a deadline; jobs stop at QAECHI_JOB_TIMEOUT_SECONDS

Before production

  • Security


    Bind the service to loopback or a private network; anyone with the token can read documents in its source folder. Keep the token in a secret store, rotate it, and leave /docs off.

  • State


    Jobs and results are kept in memory by default and are lost on restart. Copy each result into your own database as soon as the job succeeds, or plug in a persistent Store.

  • Health


    GET /health needs no token and reports the version, source backend, model and parsers. Point your load balancer and monitoring at it.

  • Versions and models


    Pin the release tag and the model ID (QAECHI_LLM_MODEL), and re-run your own samples before changing either. See Choosing an LLM.

한국어