Recipe catalog / expense-category
Match an expense to a category list
expense-category is a Jev recipe from the jev-recipes TypeScript package. Does expense clearly fall under one of the caller's categories, under several equally, under none, or is it unclear? Use it when 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.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I 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);
What input does expense-category take?
| 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
}
}What does a expense-category 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 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
}
}
Input
See shared options and behavior for client configuration, validation, and errors. Types are inferred from this folder's Zod 4 schemas.
Result
verdict is one of matched, multiple, none, unclear. unclear means the supplied facts do not establish a decision and always requires review.
A result is ready when confidence meets minConfidence and the verdict is not unclear. Inspect the verdict as well as the status: a ready result can name an outcome your application treats as negative. probabilities covers every verdict.
Reuse and calls
Uses the shared choice helper for the Jev call and response parsing. This folder owns its question, verdict criteria, and review policy. A live invocation makes one logical Jev request.
Limits
The result says only which situation holds. When it is matched, the category name still has to be extracted in a follow-up call or by a second, narrower recipe, and when it is multiple the caller decides which definition wins. The judgment uses the category definitions exactly as supplied, so vague or overlapping definitions produce multiple or unclear rather than a guess. Amounts, currency, dates, and whether the expense is allowed at all are outside this decision and belong in code or a policy check.
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo expense-category shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe expense-category to inspect the input and result schemas.
How accurate is expense-category?
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 expense-category?
- 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.
Which recipes are related to expense-category?
- 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.