Recipe catalog / expense-category
Match an expense to a category list
Does expense clearly fall under one of the caller's categories, under several equally, under none, or is it unclear?
You need to know whether a described expense can be filed under one of your own category definitions before an agent picks the category or asks the submitter for more detail.
Explore this recipe interactively ยท Source and implementation guide
Use expense-category 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 { expenseCategory } from 'jev-recipes/expense-category';
const result = await expenseCategory({
"expense": "Uber from the airport to the client's office for the Tuesday kickoff meeting, then back to the hotel.",
"categories": "Travel - Airfare: flights and airline fees.\nTravel - Ground: taxis, rideshares, rental cars, trains, and parking while traveling for business.\nMeals: food and drink while traveling or hosting clients.\nSoftware: subscriptions and licenses for work tools.\nOffice Supplies: consumable items for the office.",
"minConfidence": 0.8
});
console.log(result);
Input contract
| Field | Type | Needed |
|---|---|---|
| expense | string | Required |
| categories | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"expense": {
"type": "string"
},
"categories": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"expense",
"categories"
]
},
"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"
]
},
"verdict": {
"type": "string",
"enum": [
"matched",
"multiple",
"none",
"unclear"
]
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"probabilities": {
"type": "object",
"propertyNames": {
"type": "string",
"enum": [
"matched",
"multiple",
"none",
"unclear"
]
},
"additionalProperties": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"required": [
"matched",
"multiple",
"none",
"unclear"
]
}
},
"required": [
"model",
"usage",
"status",
"verdict",
"confidence",
"probabilities"
],
"additionalProperties": false
}
}Saved example result
This hand-authored response demonstrates the contract. It is not a model accuracy measurement. Run it without an API key: npx jev-recipes demo expense-category.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"verdict": "matched",
"confidence": 0.86,
"probabilities": {
"matched": 0.86,
"multiple": 0.08,
"none": 0.03,
"unclear": 0.03
}
}
Evaluation evidence
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.
Limitations
- Reports which situation holds (matched, multiple, none, unclear), not the name of the matched category. Extract the category name in a follow-up step once the result is matched.
- Judges the expense description against the category definitions as written. It does not know the caller's chart of accounts, tax treatment, or which category is preferred when definitions overlap.
- Amounts, dates, and receipt validity are not considered and must be checked in code.
Related recipes
- route: Use route to pick one destination from a fixed list of routes rather than to check whether a category list covers an expense at all.
- field-select: Use field-select to choose which field of a record holds a value, rather than which category definition a described purchase satisfies.