Analysis

The real cost of using an LLM as a classifier

Asking a large AI chat model to pick a category is the quickest way to build a text classifier, and often the most expensive way to run one at volume. This page breaks down where the money and the time go, and where a single-step decision model like Laya changes the maths.

7 min readLast updated

Swiss-hosted inference. Nothing you send is ever stored.Swiss data residency

In 30 seconds

  • An LLM classifier is quick to build: write a prompt listing the labels and parse the reply.
  • At volume, costs add up: the prompt is re-sent on every call, the reply is paid for, and failures need retries.
  • Each call also adds waiting time, which compounds when an AI agent makes several decisions per turn.
  • Laya answers in one pass with no generated text, and Laya Studio bills input tokens only, 30% below Jev's list price.
  • LLMs are still worth paying for when you need reasoning, explanations or very large label sets.

Code and dense tables are folded away. Open any of them on demand.

How much does it cost to use an LLM as a classifier?

The cost of an LLM classifier is more than its token price. Each call pays for the full prompt with the label list, the generated answer, retries when the output fails to parse, and the latency of generation. At volume these costs multiply per decision, which is why one-pass decision models are often cheaper for routine labelling.

An LLM classifier takes an afternoon to build. Write a prompt that lists the labels, paste in the text, ask for JSON, parse the result. No training data, no model hosting, and instruction-tuned models are genuinely good zero-shot classifiers on many tasks (Brown et al., 2020). For a prototype or a low-volume internal tool, that is often the right call.

The trouble starts when the prototype becomes a pipeline. Volume multiplies every per-call cost, latency compounds inside agent loops, and the operational burden of parsing, retrying and re-validating grows. None of these costs show up in the demo.

The anatomy of an LLM classification call

Every call pays for several things, most of which are independent of how hard the decision is:

Show technical details· 7 rows × 3 columns
Cost componentWhat drives itTypical share
System prompt and instructionsYour prompt length; repeated on every callOften the largest input share
Label list and descriptionsNumber of labels and how well they are describedGrows with label count
Few-shot examplesHow many examples you include to steer the modelCan dwarf the text itself
The text being classifiedThe input you actually care aboutOften a minority of input tokens
Output tokensJSON wrapper, label, optional rationale; hidden reasoning tokens on reasoning modelsPriced higher per token than input on most APIs
RetriesParse failures, invalid labels, timeouts, rate limitsSmall percentage, but tail-heavy
Extra callsOne call per question if prompts are separateMultiplies everything above

Put rough numbers on it with a formula rather than a price list, because prices change:

Show technical details· text sample
text
tokens_per_decision = (system + labels + examples + text) + output × output_price_ratio
monthly_cost        = volume × questions_per_item × tokens_per_decision × price_per_token × (1 + retry_rate)

A worked token count: a 400-token system prompt, 150 tokens of labels, 300 tokens of few-shot examples and a 250-token email is 1,100 input tokens, of which only 23% is the email. Add 30 output tokens for a JSON label. If you ask four separate questions about each email with separate prompts, you send the email four times and pay the fixed overhead four times. At a million emails a month, that is on the order of 4.4 billion input tokens before a single retry.

Prompt caching and batching discounts, where your provider offers them, cut the fixed overhead. Combining questions into one prompt reduces calls but makes each output longer and each parse more fragile.

Latency is a cost too

Generative decoding adds a forward pass per output token after the prompt is processed. For a short label, that is a few steps; for a JSON object with a rationale, dozens. Hosted APIs add network time and queueing.

For context, the Laya model card cites independent measurements of TypeSafe Jev, a hosted decision API, at 236 to 276 ms p50 per call, and reports Laya at 32.8 ms for a single question on a T4 GPU (multilingual checkpoint). Hosted LLM calls have their own latency profile, which varies with model size, output length and provider load; measure yours at p50 and p95. Inside an agent that makes several decisions per turn, those milliseconds add up to seconds; see latency budgets for agents.

Hidden costs: parsing, drift and probabilities

Parsing and validation. A generated label is a string. It can be misspelled, capitalised differently, wrapped in prose or replaced by a label that is not in your list. Structured-output features reduce this but do not remove the need to validate. Every validation failure is a retry or a fallback path you have to build and maintain.

Order and phrasing sensitivity. Zheng et al. (2023) showed that LLMs choosing among options have measurable position biases: moving the correct answer to a different slot changes accuracy. Label order and wording become hidden hyperparameters.

Probabilities. Token log-probabilities are not always exposed, depend on how each label tokenises, and verbalised confidence ("confidence: 0.9") is just more generated text. Kadavath et al. (2022) found models can be reasonably calibrated in some formats, but getting usable probabilities is extra engineering. Without them, you cannot threshold.

Model churn. Hosted models are updated and retired. Each change means re-running your evaluation set and possibly re-tuning prompts.

Where a one-pass decision model changes the arithmetic

A decision model such as Laya removes several rows of the cost table by construction:

Cost componentLLM classifierLaya
Output tokensPaid per callNone: output_tokens is always 0
Parsing and invalid labelsMust be handledImpossible: answers are drawn from your options
Multiple questions per itemSeveral calls or one long promptOne request, one batched forward pass
ProbabilitiesExtra engineeringReturned for every option
Few-shot examples in promptCommonNot part of the format
Model churnProvider-controlledOpen weights (Apache-2.0), pinned checkpoints

On Laya Studio, billing is per input token: 1 credit = 1 input token, the tokens the model actually reads (at most the model's context per question). Each question reads the state once, so a four-question request costs about four times the state's tokens. See /pricing for current plans and the 5 free runs.

Where the LLM is still worth paying for

Being honest about the other side:

  • Reasoning. If the decision requires reading a policy and applying it step by step, an LLM does something a 421M-parameter encoder cannot.
  • Large label spaces. Laya's accuracy falls with dozens of options (0.425 on 77-label Banking77 vs 0.870 published for Jev). An LLM reading a long label list can do better.
  • Zero-shot on idiosyncratic tasks. Laya's base checkpoints are near chance on the multi-field typed-decisions benchmark without fine-tuning.
  • Explanations. If an auditor needs a rationale, you need text.

The economical architecture is often both: a fast decision model for every item, and an LLM only for the items where the fast model's calibrated confidence is low. See act or escalate.

Replacing a four-question LLM prompt with one Laya Studio call

Show technical details· bash sample
bash
curl -s https://api.laya.studio/v1/systemone \
  -H "Authorization: Bearer $LAYA_STUDIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "state": {"from": "ap@contoso.example", "subject": "Overdue: invoice 8812", "body": "Our records show invoice 8812 unpaid for 45 days. Please remit this week to avoid a hold on your account."},
    "questions": {
      "category": {
        "type": "choice",
        "instructions": "Which team should handle the email in body?",
        "criteria": {"billing": "invoices, payments, refunds", "technical": "bugs, outages, integrations", "sales": "pricing, demos, new purchases", "security": "phishing, scams, account compromise", "other": "none of the above"}
      },
      "is_phishing": {
        "type": "noul",
        "instructions": "Is this email a phishing or scam attempt to steal money, credentials, or personal data?",
        "criteria": {"true": "phishing, scam, or fraud", "false": "a legitimate email"}
      },
      "urgency": {"type": "score", "instructions": "How urgent is the request in body?", "criteria": ["no time pressure", "needs attention soon", "blocking issue or hard deadline"]},
      "needs_reply": {"type": "noul", "instructions": "Does the sender expect a reply?"}
    }
  }'

Four questions, one call, billed per input token, no output tokens and no parsing. Compare accuracy on your own labelled sample before switching: the right answer depends on your task. Sign up and see the docs.

Frequently asked questions

Is an LLM classifier always more expensive than Laya?
Per decision, a generative call usually costs more because of prompt overhead, output tokens and retries, but the only honest comparison is on your volume and your prompts. Use the formula above with your provider's prices and Laya Studio's per-question credits.
Can I cut LLM classification cost with prompt caching?
Yes, caching and batch discounts reduce the fixed prompt overhead substantially where available. They do not remove output tokens, parsing, or per-call latency.
Does Laya charge by token?
Yes, by input token only: 1 credit = 1 input token, 30% below Jev's list price, and there are no output tokens because Laya generates none. Long states are truncated to the model's context, so you never pay for tokens it did not read.
When should I keep the LLM?
When the decision needs reasoning, a written rationale, dozens of labels in one question, or strong zero-shot performance on an unusual task. Many teams keep the LLM as the escalation path for low-confidence cases.
Does an LLM give me probabilities I can threshold?
Sometimes, through token log-probabilities, but they depend on label tokenisation and are not always exposed. Verbalised confidence is generated text and needs its own calibration. Laya returns a full distribution per question by design.
How do I estimate what LLM classification will cost?
Multiply your monthly decisions by the per-call cost: prompt tokens (instructions, label list and text) times the input price, plus output tokens times the output price, plus an allowance for retries on unparseable answers. Then compare with a per-question price at the same volume.
Is a small classifier cheaper than an LLM?
At high volume a small encoder is usually cheaper to run per decision. A conventionally fine-tuned one also costs labelled data, training time and a deployment per task. A request-time-schema model like Laya sits in between: small and fast, with labels supplied per call. Compare on your own volume and accuracy target.

Sources

Last updated . Laya Studio is an independent hosted service for the open-source Laya model (Apache-2.0, © Convai Innovations) and is not affiliated with Convai Innovations or TypeSafe.