Structured extraction schema token cost
When you use function calling or JSON-schema structured output, the schema itself is part of the prompt — it is re-sent on every request. A rich 50-field schema with descriptions can quietly add hundreds of input tokens to each call. Paste two schemas, set your daily volume, and this tool shows the per-request token overhead and the monthly cost difference.
How it works
The tool measures each schema’s character length and estimates tokens at the standard ~4 characters per token ratio that compact JSON tends to follow. It then multiplies the per-request overhead by your daily request count and your model’s input price (per million tokens) to project monthly spend for each schema:
schema_tokens ≈ schema_characters / 4
monthly_cost = schema_tokens / 1,000,000 × input_price × requests/day × 30
The difference between the two schemas is the money you save (or spend) purely by changing the shape of what you extract.
Worked example
Suppose you extract invoice data. A “rich” schema with 40 fields and verbose descriptions weighs around 2,800 characters — roughly 700 tokens. A lean schema with 8 essential fields might be 400 characters — around 100 tokens. That is a 600-token difference per request.
At 10,000 requests per day and an input price of $2 per million tokens, the monthly overhead is:
Rich: 700 tokens × 10,000/day × 30 days / 1,000,000 × $2 = $4.20/month
Lean: 100 tokens × 10,000/day × 30 days / 1,000,000 × $2 = $0.60/month
Saving: $3.60/month
That looks modest, but at 500,000 daily requests the same gap becomes $180 a month saved from a schema redesign alone — with no model upgrade required.
What actually inflates schema size
Understanding which parts of a JSON schema are token-heavy helps you target cuts without losing extraction accuracy:
- Field descriptions are the biggest culprit. A
descriptionstring explaining whatinvoice_datemeans adds ~10–20 tokens per field. Remove them or condense to two or three words once the model is behaving correctly. - Nested objects compound costs: each nesting level repeats
type,properties, andrequiredboilerplate. Consider flattening when depth is not semantically meaningful. - Enum lists are verbatim strings. An enum with 30 country codes adds roughly 80 tokens; a free-text field with a prompt note costs far less.
- Verbose field names accumulate. The 50 extra characters between
dobanddateOfBirthInISO8601Formatonly cost ~12 tokens once, but multiplied over millions of calls that is real money.
Tips and notes
- Strip long human-readable
descriptionstrings from production schemas — they are billed on every call but rarely improve extraction accuracy enough to justify the cost at high volume. - Prefer short, unambiguous field names over verbose ones;
dobcosts fewer tokens thandateOfBirthInISO8601Formatacross millions of requests. - If only a few requests need the rich 50-field schema, route those separately and keep the cheap 5-field schema as your default path.
- Use this tool iteratively: after trimming a schema, paste both the old and new versions to quantify exactly what you saved before deploying.
- The 4 characters per token heuristic is a reasonable budget estimate. For a
precise count, run both schemas through the model’s own tokenizer (the
tiktokenlibrary for OpenAI models, for example) once you have finalised the design.