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.parserand callparse(). No server, no token, no network hop.Use when your app is Python: scripts, notebooks, FastAPI or Django back ends, batch jobs.
-
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.
Declare the dependency¶
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¶
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)!
}
- How it was read:
parser,llm, orstub(no source or no model configured; every value isnull). - A second check on the result:
yes,noorunknown. Treat it as a signal, not a guarantee. - Numbers come back as numbers:
(5000)becomes-5000,1,200,000becomes1200000. - The exact text the value was read from, and its page. Show it next to the value in your UI.
nullmeans no evidence was found. It is never a guess. Route it to review, do not store it as zero.- Quotes the model gave that are not in the document. Anything listed here needs a human.
- 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
/docsoff. -
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 /healthneeds 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.