
I Had OpenAI's Decisions API Classify Document Types and Compared It with Clef
This page has been translated by machine translation. View original
Hello, I'm Keima.
I Had Cloudflare's Clef Classify Document Types | DevelopersIO I gave Cloudflare's Clef only document images and had it classify them into types such as invoice and quotation. It classified 27 of 28 correctly, and the one it got wrong could be identified by its low confidence.
OpenAI's Decisions API (model: gpt-6-luna) can also receive images and choose one from a set of choices, so it should be usable in a similar way.
So this time, I gave the Decisions API the same 28 images and the same question as in the Clef test, and compared accuracy, confidence, processing time, and cost with Clef.
I hope this is helpful when you are considering which to use for automatic document sorting.
1. Test conditions
| Item | Details |
|---|---|
| Model | Decisions API gpt-6-luna. Clef's clef and clef-flash are used for comparison |
| Input | One document image (PNG, 1240×1754). The document text is not provided |
| Documents | 28 fictional documents (14 Japanese, 14 English) |
| Question | One choice question. 8 choices: 7 types plus other |
| How it was called | REST API, one request per image, once each |
choice is a question type that returns the selected choice, the probability of each choice, and a confidence (confidence).
The probabilities are values that sum to 1 across the 8 choices, and the confidence expresses on a 0 to 1 scale how decisively the answer was chosen.
In the Clef test, having a person check only the documents with a confidence below 0.8 was enough to catch every misclassification.
The request to the Decisions API looks like this (only 2 of the 8 choices are shown).
The comments are for explanation and are not included in the JSON actually sent.
{
"model": "gpt-6-luna",
"input": [{
"role": "user",
"content": [
// Premise for the judgment (the attached image is one page of a business document; determine what kind of document it is)
{"type": "input_text", "text": "The attached image is one page of a business document. Decide what kind of document it is."},
{"type": "input_image", "image_url": "data:image/png;base64,..."}
]
}],
"questions": [{
"type": "choice", // Choose one from the choices
"name": "doc_type",
// Which kind of business document is shown in the image?
"instructions": "Which kind of business document is shown in the image?",
"choices": [
// invoice: a document requesting payment for goods or services already provided (with an amount due and a payment deadline)
{"value": "invoice", "description": "Invoice / bill: the seller requests payment for goods or services already provided, with an amount due and a payment deadline."},
// quotation: a document proposing prices before an order is placed (usually with a validity period)
{"value": "quotation", "description": "Quotation / estimate: the seller proposes prices before an order is placed, usually with a validity period."}
]
}]
}
2. Data
The data is the same as in the Clef test.
For each of the 7 types (invoice, quotation, receipt, delivery note, purchase order, contract, and resume), I prepared 2 documents each in Japanese and English, and the second document of each pair contains confusing elements such as the following.
-
The title is missing, small, or an alternative name (Estimate, Packing Slip, Purchase Order, Work History)
-
The body text mentions a different document (a quotation number in the body of an invoice, a purchase order and an invoice in the notes of a quotation)
-
A resume filled with business-document terminology (work experience handling invoices and purchase orders)

An example with confusing elements. There is no title, and the body mentions a quotation number
3. Results
The characteristics of the 28 documents and each model's answer and confidence are as follows (errors are in bold).
| Correct answer | Language | Document characteristics | Decisions API | clef | clef-flash |
|---|---|---|---|---|---|
| Invoice | Japanese | Standard (with the title "Invoice") | Invoice 1.0 | Invoice 0.9416 | Invoice 0.8884 |
| Invoice | Japanese | No title. Body mentions a quotation number | Invoice 1.0 | Invoice 0.948 | Invoice 0.9439 |
| Invoice | English | Standard (titled "INVOICE") | Invoice 1.0 | Invoice 0.957 | Invoice 0.9131 |
| Invoice | English | No title. Body mentions the number of an accepted quotation | Invoice 1.0 | Invoice 0.9619 | Invoice 0.9386 |
| Quotation | Japanese | Standard (with the honorific title "Quotation") | Quotation 1.0 | Quotation 0.9265 | Quotation 0.9105 |
| Quotation | Japanese | Only a small "Estimate" in the upper right as the title. Mentions a purchase order and an invoice | Quotation 1.0 | Quotation 0.8698 | Invoice 0.5175 |
| Quotation | English | Standard (titled "QUOTATION") | Quotation 1.0 | Quotation 0.9507 | Quotation 0.9416 |
| Quotation | English | Title is the alternative name "Estimate". States "This is not an invoice" and also mentions a purchase order | Quotation 1.0 | Quotation 0.9437 | Quotation 0.9044 |
| Receipt | Japanese | Standard (with the title "Receipt", a purpose-of-payment line, and a revenue stamp field) | Receipt 1.0 | Receipt 0.9126 | Receipt 0.7957 |
| Receipt | Japanese | POS receipt with no title (amount tendered, change) | Receipt 1.0 | Receipt 0.9597 | Receipt 0.9115 |
| Receipt | English | Standard (titled "RECEIPT", PAID IN FULL) | Receipt 1.0 | Receipt 0.9707 | Receipt 0.9491 |
| Receipt | English | Title is the alternative name "Payment Confirmation". The table lists an invoice number and an invoiced amount | Receipt 1.0 | Receipt 0.9687 | Receipt 0.9017 |
| Delivery note | Japanese | Standard (with the title "Delivery Note" and a receipt stamp field) | Delivery note 1.0 | Delivery note 0.8453 | Delivery note 0.8766 |
| Delivery note | Japanese | Small title "Delivery Note (Copy)". Mentions a purchase order number, no amount field | Delivery note 1.0 | Delivery note 0.9429 | Delivery note 0.9338 |
| Delivery note | English | Standard (titled "DELIVERY NOTE", with a receipt signature field) | Delivery note 1.0 | Delivery note 0.9601 | Delivery note 0.9399 |
| Delivery note | English | Title is the alternative name "Packing Slip". Mentions the customer's PO number, no amount field | Delivery note 1.0 | Delivery note 0.9542 | Delivery note 0.8768 |
| Purchase order | Japanese | Standard (with the title "Order Form") | Purchase order 1.0 | Purchase order 0.9106 | Purchase order 0.9293 |
| Purchase order | Japanese | Titled "Purchase Order" (an alternative Japanese term). Mentions three documents: quotation, delivery note, and invoice | Purchase order 1.0 | Invoice 0.2384 | Purchase order 0.9436 |
| Purchase order | English | Standard (titled "PURCHASE ORDER") | Purchase order 1.0 | Purchase order 0.9586 | Purchase order 0.9461 |
| Purchase order | English | No title. Only "Please supply the following items" and an approver field | Purchase order 1.0 | Purchase order 0.9506 | Purchase order 0.9477 |
| Contract | Japanese | Standard (non-disclosure agreement) | Contract 1.0 | Contract 0.9597 | Contract 0.9167 |
| Contract | Japanese | Service outsourcing agreement. The compensation clause mentions a quotation and an invoice | Contract 1.0 | Contract 0.9543 | Contract 0.9009 |
| Contract | English | Standard (NON-DISCLOSURE AGREEMENT) | Contract 1.0 | Contract 0.9666 | Contract 0.8993 |
| Contract | English | Master Services Agreement. Clause headings include Purchase Orders and Invoices and Payment | Contract 1.0 | Contract 0.9679 | Contract 0.9388 |
| Resume | Japanese | Standard (titled "Resume", close to the JIS format, with a photo field) | Resume 1.0 | Resume 0.9036 | Resume 0.9211 |
| Resume | Japanese | Not "Resume" but "Work History". The body is full of the words quotation, purchase order, and invoice | Resume 1.0 | Resume 0.8985 | Resume 0.8865 |
| Resume | English | A small "RESUME". The body is full of the words invoices, purchase orders, and receipts | Resume 1.0 | Resume 0.949 | Resume 0.9358 |
| Resume | English | No title. A researcher's CV with only a name and headings (a paper title contains "invoices") | Resume 1.0 | Resume 0.9065 | Resume 0.916 |
3.1 Accuracy
| Condition | Decisions API | clef | clef-flash |
|---|---|---|---|
| Overall | 28 / 28 | 27 / 28 | 27 / 28 |
| Japanese | 14 / 14 | 13 / 14 | 13 / 14 |
| English | 14 / 14 | 14 / 14 | 14 / 14 |
| Documents with confusing elements (the second of each pair) | 14 / 14 | 13 / 14 | 13 / 14 |
The Decisions API classified all 28 documents correctly.
It also correctly classified the Japanese purchase order and the quotation with a small title, which were each missed by one of the two Clef models.
3.2 Confidence
The Decisions API's confidence was 1.0 for all 28 documents, with a probability of 1.0 for the chosen type and 0.0 for the other 7 types.
Clef, on the other hand, had confidence scattered between 0.7957 and 0.9707 even for correctly classified documents, and it dropped to 0.2384 and 0.5175 for the misclassified ones.
With these 28 documents, the Decisions API's confidence could not be used to identify "documents it was unsure about".
Since every answer was correct there was no real harm, but to set up an operation like the Clef test's "have a person check only documents with confidence below 0.8", we would need to verify with other data whether the Decisions API's confidence drops when it misclassifies.
3.3 Time and cost
Time is the measured round-trip time of REST API calls from Japan, and the conversion rate is 150 yen to the dollar.
| Model | Round-trip time (median) | Input tokens (per image) | Input price (per 1M tokens) | Cost (28 images) |
|---|---|---|---|---|
| Decisions API | 0.517 s (517 ms) | 2,444 | $0.10 | $0.0068 (about 1.03 yen) |
| clef | 0.976 s (976 ms) | 1,367 | $0.24 | $0.0092 (about 1.38 yen) |
| clef-flash | 0.3535 s (354 ms) | 1,367 | $0.09 | $0.0034 (about 0.52 yen) |
For the same images, the Decisions API used about 1.8 times as many input tokens as Clef, but because its unit price is lower, the cost came to about three quarters of clef's.
With the Decisions API too, only input tokens are charged.
Input costs $0.10 per 1M tokens. You pay only for input tokens: there are no cache-read, cache-write, or output-token charges.
Source: Decisions API | OpenAI API
4. Summary
In this test of 28 documents, the Decisions API classified all of them correctly, including the Japanese documents that the two Clef models missed, and the cost also came in lower than clef.
Models like Jev and Clef are often English-centric and still have challenges with Japanese, but since the Decisions API is based on Luna, I got a strong sense that it is also good with Japanese business documents.
On the other hand, as a decision model to embed in a business system, the confidence value that shows how sure the model is will be the key to operational design.
If confidence is returned as 1.0 for every judgment, we cannot design an escalation that routes documents at risk of misclassification to human review, and running an automation system on its own remains a concern.
In real operation, what matters is not that it always outputs 1.0, but whether the value drops appropriately when the model is unsure.
The sample conditions I prepared this time may have been favorable, and the judgments may have been easy for the model.
I plan to investigate further with more confusing documents and more diverse samples, determine how much the confidence varies and where to set a suitable threshold, and then proceed with embedding it into a system.
