Recipe catalog / invoice-facets
Label what an invoice states
invoice-facets is a Jev recipe from the jev-recipes TypeScript package. Which of these does invoice state: vendor identity, an invoice number, a due date, line items, a tax or total breakdown? Use it when you need several independent presence checks on invoice text in one call, to spot missing fields before routing it for approval or entry.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use invoice-facets in TypeScript?
Install with npm install jev-recipes. Requires Node.js 22.9 or newer and ES modules. Set TYPESAFE_API_KEY in your server environment for live calls, which send input to TypeSafe and use API quota. See the installation guide.
import { invoiceFacets } from 'jev-recipes/invoice-facets';
const result = await invoiceFacets({
"invoice": "Northwind Design Studio\n412 Harbor St, Portland OR\n\nINVOICE #2024-0187\nBill to: Acme Robotics, Attn: Accounts Payable\n\n1. Landing page redesign, 24 hrs @ $120/hr ........ $2,880.00\n2. Icon set (32 icons) ................................ $640.00\n\nSubtotal: $3,520.00\nTax (0%): $0.00\nTotal due: $3,520.00\n\nThank you for your business.",
"minConfidence": 0.8
});
console.log(result);
What input does invoice-facets take?
| Field | Type | Needed |
|---|---|---|
| invoice | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"invoice": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"invoice"
]
},
"result": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"model": {
"type": "string"
},
"usage": {
"type": "object",
"properties": {
"input_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"output_tokens": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
},
"required": [
"input_tokens",
"output_tokens"
],
"additionalProperties": false
},
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"detected": {
"type": "array",
"items": {
"type": "string",
"enum": [
"statesVendor",
"statesInvoiceNumber",
"statesDueDate",
"statesLineItems",
"statesTotals"
]
}
},
"labels": {
"type": "object",
"properties": {
"statesVendor": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"statesInvoiceNumber": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"statesDueDate": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"statesLineItems": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
},
"statesTotals": {
"type": "object",
"properties": {
"status": {
"type": "string",
"enum": [
"ready",
"review"
]
},
"verdict": {
"type": "string",
"enum": [
"present",
"absent"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"status",
"verdict",
"probability",
"confidence"
],
"additionalProperties": false
}
},
"required": [
"statesVendor",
"statesInvoiceNumber",
"statesDueDate",
"statesLineItems",
"statesTotals"
],
"additionalProperties": false
}
},
"required": [
"model",
"usage",
"status",
"detected",
"labels"
],
"additionalProperties": false
}
}What does a invoice-facets result look like?
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo invoice-facets.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"detected": [
"statesVendor",
"statesInvoiceNumber",
"statesLineItems",
"statesTotals"
],
"labels": {
"statesVendor": {
"status": "ready",
"verdict": "present",
"probability": 0.97,
"confidence": 0.97
},
"statesInvoiceNumber": {
"status": "ready",
"verdict": "present",
"probability": 0.95,
"confidence": 0.95
},
"statesDueDate": {
"status": "ready",
"verdict": "absent",
"probability": 0.12,
"confidence": 0.88
},
"statesLineItems": {
"status": "ready",
"verdict": "present",
"probability": 0.93,
"confidence": 0.93
},
"statesTotals": {
"status": "ready",
"verdict": "present",
"probability": 0.96,
"confidence": 0.96
}
}
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
Result
labels holds one check per label: statesVendor, statesInvoiceNumber, statesDueDate, statesLineItems, statesTotals. Each check has a verdict of present or absent, the yes probability, confidence for the chosen side, and its own status. detected lists the present labels in declaration order.
The overall status is review when any single label falls below minConfidence. Labels that are individually ready remain usable in that case.
Reuse and calls
Uses the shared labels helper, which places one yes/no question per label in a single Jev request. This folder owns the questions and their outcome descriptions. A live invocation makes one logical Jev request.
Limits
Every label is a presence check on the supplied text. A stated invoice number, due date, or total is reported as present even if it is wrong, duplicated, or inconsistent with the line items, so parse and validate values in code. Payment terms such as "Net 30" count as stating a due date even though the actual date must be computed by the caller. The recipe does not judge whether the invoice is genuine, matches a purchase order, or should be paid.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo invoice-facets shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe invoice-facets to inspect the input and result schemas.
How accurate is invoice-facets?
No verified live accuracy measurement is available. Evaluate representative cases before using this decision in your workflow.
Use the evaluation guide to measure this decision on your own labeled cases.
What are the limits of invoice-facets?
- Each label reports whether the invoice text states the item, not whether the stated value is correct, consistent, or matches a purchase order.
- Numbers, dates, and totals are not validated. Parse and check them in code.
- Labels are independent, so an invoice can carry several, all, or none.
Which recipes are related to invoice-facets?
- clarify: Use clarify to decide whether a request about an invoice is too ambiguous to act on, rather than what the invoice text itself states.
- field-select: Use field-select to pick which field of a record a value belongs to, rather than to check which fields the invoice text contains at all.