Recipe catalog / format-fit
Check requested format compliance
format-fit is a Jev recipe from the jev-recipes TypeScript package. Does response follow the structure or format request explicitly asks for, such as a list, table, JSON, item count, sections, or language? Use it when you need a yes/no check that a generated response honored the format the prompt or user explicitly asked for.
Last updated .
Explore this recipe interactively · Source and implementation guide · Markdown version
How do I use format-fit 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 { formatFit } from 'jev-recipes/format-fit';
const result = await formatFit({
"request": "Give me three benefits of unit testing as a numbered list, one sentence each.",
"response": "1. Unit tests catch regressions close to the change that caused them.\n2. They document how each function is expected to behave.\n3. They make refactoring safer because failures point to a specific unit.",
"minConfidence": 0.8
});
console.log(result);
What input does format-fit take?
| Field | Type | Needed |
|---|---|---|
| request | string | Required |
| response | string | Required |
| minConfidence | number | Optional |
Full input and result schemas
{
"input": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"request": {
"type": "string"
},
"response": {
"type": "string"
},
"minConfidence": {
"type": "number",
"minimum": 0,
"maximum": 1
}
},
"required": [
"request",
"response"
]
},
"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"
]
},
"probability": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"confidence": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"verdict": {
"type": "string",
"enum": [
"follows",
"deviates"
]
}
},
"required": [
"model",
"usage",
"status",
"probability",
"confidence",
"verdict"
],
"additionalProperties": false
}
}What does a format-fit 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 format-fit.
{
"model": "demo-fixture",
"usage": {
"input_tokens": 0,
"output_tokens": 0
},
"status": "ready",
"probability": 0.95,
"confidence": 0.95,
"verdict": "follows"
}
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 follows when Jev's yes probability is at least 0.5 and deviates otherwise. probability is that yes probability. confidence is the probability of the chosen side, so a 0.1 yes probability yields deviates with 0.9 confidence.
A result is ready when confidence meets minConfidence. Otherwise it is review. A sensible default for review is to regenerate or route the response to a person rather than send it.
Reuse and calls
Uses the shared gate helper, a single yes/no question. This folder owns the question wording, the outcome descriptions, and the review policy. A live invocation makes one logical Jev request.
Limits
The recipe checks the format instructions stated in request: list or table shape, machine formats, item counts, named sections, and the language of the answer. It does not judge whether the content is correct, and a request with no format instruction grades follows. The judgment is semantic, so strict machine formats such as JSON, CSV, or a schema should also be validated in code; use this recipe for the parts a parser cannot see, such as "three items" or "answer in Spanish".
Example input
demo.json contains editable input and a hand-authored response. After installing jev-recipes, npx jev-recipes demo format-fit shows an offline illustration, not an accuracy measurement. Use npx jev-recipes describe format-fit to inspect the input and result schemas.
How accurate is format-fit?
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 format-fit?
- Judges structure semantically. Strict machine formats such as JSON or CSV should also be validated in code.
- Checks only format instructions stated in the request. It does not judge content accuracy or implied conventions.
Which recipes are related to format-fit?
- instruction-fit: Use instruction-fit to check the response against all instructions, not only format.
- tone-check: Use tone-check when the requirement is about voice or register rather than structure.