The short version: don’t fixate on unit price

The usual first step in evaluating LLM APIs is a spreadsheet of per-million-token prices. It’s a useful reference and an easy way to make a bad decision. Prices change often, so today’s cheapest option may not be cheapest in a few months. And a low-priced model that needs longer prompts, more retries, or human rework because its output falls short can cost more overall.

A more reliable approach: define the business need and quality bar first, then calculate the all-in cost of completing one task, and finally weigh compliance, reliability and vendor risk. This article lists no prices. It covers the factors that drive cost and choice.

Understand the billing model

Most major LLM APIs bill by token, but the details vary a lot. At minimum, find out:

  • Input and output are priced separately, and output usually costs more. A long-form generation workload and a classification or extraction workload have very different cost profiles.
  • Many providers discount cached context, so repeated input that hits the cache costs less. If your requests share a long system prompt or knowledge snippets, this matters a great deal.
  • Batch endpoints are usually cheaper than real-time ones and suit latency-tolerant offline work such as bulk tagging or summarisation.
  • Reasoning models generate extra “thinking” tokens, so a short final answer can still produce a sizeable bill.
  • Images, speech, embeddings, web search and code execution are often billed separately.

Also check rate limits, concurrency caps and the quota request process. A good price doesn’t help if you’re throttled at peak times.

Count the hidden costs

Beyond the API invoice, several costs are easy to overlook.

Engineering: prompt design, context management, output parsing, retries and fallbacks all have to be built and maintained. After a model upgrade, prompts may need re-tuning.

Evaluation: knowing whether a model is good enough requires a test set, metrics, and a re-run every time you switch models or versions. Teams often skip this, yet it is what gives every later decision a basis.

Quality: when output is wrong, someone may have to review or redo it. In customer service, legal or healthcare settings the cost of an error far exceeds the cost of the call.

Operations: logging, monitoring, usage alerts, key management and auditing are all mandatory in production.

Choose models by task tier

Not every task needs the strongest model. A practical method is to tier your tasks.

Simple tasks, such as intent classification, field extraction and format conversion, are usually handled well by small or lightweight models with low cost and latency. Medium tasks, such as summarising, rewriting and general Q&A, fit mid-range models that balance quality and cost. Complex tasks, such as multi-step reasoning, code generation, long-document analysis and agent work, go to the most capable models.

On top of that, you can add model routing: try a cheaper model first and escalate to a stronger one when confidence is low or the task is complex. Combined with caching and batching, this can keep costs well under control without a noticeable drop in quality. How much you save depends on your traffic mix, so measure it on your own data.

Deployment trade-offs

There are three common ways to connect, each with its place.

The first is calling a model provider’s API directly: Qwen models via Alibaba Cloud Model Studio, Doubao models via Volcano Engine, or open platforms such as Google AI Studio and Zhipu’s BigModel. Integration is simple and new models arrive immediately, but you depend on one vendor’s pricing, quotas and uptime.

The second is going through an aggregator such as OpenRouter, SiliconFlow or iFlytek Xingchen MaaS. One interface reaches many models, which makes comparison and switching easy and lets you fail over when a provider has problems. The trade-off is an extra intermediary: your data passes through the platform, so review its data handling policy and service terms.

The third is self-hosting open models. Ollama is a quick way to try them locally, model hubs such as ModelScope supply weights, and dedicated inference frameworks take them to production. Data stays inside your network and costs are predictable, but you need to buy or rent GPUs and staff the operations and optimisation work. At low volume, self-hosting rarely wins on unit cost; it makes more sense with large, steady volume or strict data compliance requirements.

Many companies end up with a hybrid: sensitive data on self-hosted models, general tasks on cloud APIs, and an application platform such as Dify orchestrating both.

Compliance and data security

Offering generative AI services to the public in mainland China involves filing and security assessment requirements, and calling overseas models raises cross-border data transfer questions. Even for internal use, find out:

  • Whether the provider trains on your request data, and whether you can opt out.
  • Which region stores the data and for how long.
  • Whether enterprise agreements, data processing agreements and security certifications are available.
  • Whether sector-specific rules in finance, healthcare or government can be met.

The answers often decide the outcome more than any price difference.

Reduce vendor lock-in

The model market moves fast. Today’s leader can be overtaken tomorrow, and prices and terms can change. To keep your options open, build in a few safeguards:

  • Put an abstraction layer between business code and model APIs, with unified request and response formats.
  • Prefer common interface conventions; many providers and aggregators support OpenAI-style APIs.
  • Manage prompts, evaluation sets and evaluation scripts as assets so you can re-test quickly when switching.
  • Keep at least one backup model and rehearse switching to it.

An actionable evaluation sequence

Putting it together:

  1. Map your use cases, tier tasks by complexity and define a quality bar for each tier.
  2. Build an evaluation set from your real data. It needn’t be large, but it must be representative.
  3. Shortlist two or three models per tier and compare quality, latency and cost per task on that set.
  4. Choose a deployment approach based on compliance requirements and data sensitivity.
  5. Launch with a small share of traffic and monitor real usage, error rates and user feedback.
  6. Re-evaluate regularly, track new models and price changes, and adjust routing as needed.

Cost control isn’t a one-off choice; it’s an ongoing process. Building the ability to evaluate is worth more over time than finding any single “cheapest model.”