ส่งไฟล์เป็น base64 ในฟิลด์ document และส่งฟิลด์ที่ต้องการเป็น schema รูปภาพนับเป็นหนึ่งหน้า คู่มือ Document Extraction อธิบายภาษาสคีมา ชนิดฟิลด์ทุกชนิด กฎการนับฟิลด์ย่อย และวิธีอ่าน missing unverified truncated และ assumed สคีมาที่อยู่นอกภาษาสคีมาตอบ 400 schema_invalid พร้อม path และ reason โดยไม่คิดเครดิต
เฮดเดอร์#
authorizationBearer pxa_...จำเป็นAuthorization: Bearer pxa_... (recommended).
x-api-keypxa_...Alternative to the Authorization header. Ignored when Authorization is present.
idempotency-keystringMakes a retry safe. Two requests carrying the same key charge once and synthesize the same content. One request per key runs at a time. A concurrent duplicate answers 409 idempotency_in_flight. Reuse a key only to retry an identical request. A changed payload is rejected with 422. Accepts up to 200 printable ASCII characters.
เนื้อหา#
documentstringจำเป็นThe document to extract from, as the base64 encoding of a PDF, PNG, JPEG, or WebP file. An image counts as one page. Cost is 13 credits per page for a schema of up to 50 leaf fields and 19.5 credits per page beyond that, charged before extraction and refunded automatically when extraction fails. A PDF may carry up to 20 pages, and more answers 400 too_many_pages. The decoded file may be up to 10,485,760 bytes, and larger answers 413 document_too_large. A file that cannot be read as one of the four formats answers 400 document_invalid, and a PDF that needs a password to open answers 400 document_password_required. Send one document per request. A file holding several documents gets one object, with no promise which document it describes. GET /v1/models reports the ceilings as max_pages, max_bytes, and max_leaves.
modelstringจำเป็นExtraction model id, for example paxa-doc-extract-v1. The id is the contract version: the dialect, the response shape, and the leaf-counting rule are fixed under it, and a change ships as a new id served beside it. GET /v1/models lists the served catalog.
schemaobjectจำเป็นThe fields to extract, as an object with one key, fields, mapping each field name to its definition. A definition carries a type, an optional required flag, an optional description of up to 200 characters the model reads, and the keys its type offers. Leaf types: "string", "integer", "number", "date", "time", "enum", "id", "thai_id", "email", "phone", "postal_code", "province", "bank", "insurer", "card_scheme", "payment_method", "legal_form", "currency", "unit", "amount_words". Containers: "object" with its own fields, and "array" with items (a leaf or an object) and a required max_items of 1 to 200. Names are 1 to 64 characters of letters, digits, and underscores. At most 3 containers sit below the root. An array holds leaves or objects, and an array inside an array is refused. The schema's leaf count is every leaf once plus every leaf inside an array once per element the array is sized for, and it must stay within the model's max_leaves. A schema outside the dialect answers 400 schema_invalid with the offending path and a reason, uncharged. A serialized schema over 131,072 bytes answers the same code with reason too_large. The Document Extraction guide is the full reference for every type, its keys, and its delivered form.
include_pagesbooleantrue adds a pages array to the response: the text read from each page as GitHub-flavored Markdown, the reading the fields were extracted from, at no extra charge. Omitted, the response carries the fields alone.
include_evidencebooleantrue adds an evidence object to the response, mapping each field path to the printed span its value was read from, whether or not a value could be read from it. Costs nothing extra. Omitted, the response carries no spans.
การตอบกลับ#
The filled-in schema.
status"complete" or "incomplete"จำเป็น"complete" when every required field carries a value, "incomplete" otherwise. Computed from the fields alone. A file that is not what the schema describes comes back "incomplete" with most required fields in missing, which is the wrong-document signal.
fieldsobjectจำเป็นYour schema's tree with plain values. A string field carries the printed text and a number or integer field a number. A date is ISO YYYY-MM-DD and a time is 24-hour HH:MM, with seconds when printed. An enum carries one listed value, and a closed-set field the form its format asked for. Null wherever nothing was read. Every value is a span printed in the document, or null. Nothing is inferred, computed, or looked up.
missingarray of stringsจำเป็นEvery required field delivered as null, for any reason.
unverifiedarray of objectsจำเป็นEvery field delivered as null because its span could not be read as the field's type, each with its reason. Empty when every value stood.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
unverified[].pathstringจำเป็นThe field delivered as null. Paths are in dot form, array elements indexed: "items[2].amount".
unverified[].reasonstringจำเป็นWhy the span could not stand as the field's value: one of not_in_readout, not_as_printed, no_number, ambiguous_number, not_an_integer, no_date, ambiguous_date, no_time, ambiguous_time, not_an_enum_value, ambiguous_match, not_13_digits, bad_checksum, wrong_digit_count, not_an_email, not_a_phone, not_a_postal_code, no_amount_words, below_min, above_max, too_many_decimals, too_short, too_long, pattern_mismatch, before_min, after_max, in_the_future. The Document Extraction reference states each one.
truncatedarray of stringsจำเป็นEvery array whose document carried more elements than it was sized for. The first max_items elements are in fields, in reading order. Raise max_items to read the rest. Empty when every array fit.
assumedarray of objectsจำเป็นEvery date whose year was printed with two digits, with the digits and the year delivered. Always present and empty when nothing was assumed. A caller who would rather decide the era reads it here.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
assumed[].pathstringจำเป็นThe date field. Paths are in dot form, array elements indexed: "items[2].amount".
assumed[].printedstringจำเป็นThe two digits of the year as printed, for example "69".
assumed[].read_asintegerจำเป็นThe four-digit year delivered in the field, in the Common Era.
evidenceobjectField path to the printed span the value was read from, for every field whose span the reading carries. Present when the request set include_evidence to true.
pagesarray of objectsOne entry per page of the document, in page order. The fields were extracted from this reading. Present when the request set include_pages to true.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
pages[].pageintegerจำเป็นPage number, starting at 1. An image request has exactly one page.
pages[].markdownstringจำเป็นThe page's content as GitHub-flavored Markdown, in reading order. The fields were read from this text.
usageobjectจำเป็นWhat the request was billed for.
ดูฟิลด์ย่อยซ่อนฟิลด์ย่อย
usage.pagesintegerจำเป็นPages this request was billed for.
usage.leavesintegerจำเป็นThe schema's leaf count, which decides the per-page rate: up to 50 bills at credits_per_page, more at large_schema_credits_per_page.
usage.creditsnumberจำเป็นWhat this delivery cost, in credits, exact to a hundredth. An idempotent replay reports the ORIGINAL request's charge, since that one charge is what paid for this delivery too; your balance moves only once.