Batch API or real-time calls: how to choose the right channel for different workloads
Cost optimization8 мин чтенияИсточник: Admesh 技术团队

Batch API or real-time calls: how to choose the right channel for different workloads

Both Anthropic and OpenAI offer batch processing channels, trading a lower unit price for longer response times. This article provides an actionable decision framework: which tasks should go through batch, which must go real-time, and how to manage both types of traffic with the same gateway.

First, distinguish the two time scales

LLM calls vary enormously in their sensitivity to time. A user waiting for a reply in a chat box tolerates seconds; a team's daily report generation task may tolerate hours. The batch channel is designed for the latter: it queues requests, processes them in bulk, and trades a longer completion time for a lower per-token price.

Anthropic's [batch processing docs](https://platform.claude.com/docs/en/build-with-claude/batch-processing) and [pricing page](https://claude.com/pricing) both list batch-tier prices separately; OpenAI also has corresponding batch and batch processing discounts. What they share is a discount off the standard price; what differs is the submission method and completion window.

Decision framework: four questions

  1. Is someone synchronously waiting for this result? Yes → real-time. No → continue.
  2. Can the result be a few hours late? Yes → batch candidate. Must be minute-level → real-time.
  3. Is the request set something that can be enumerated offline? Yes (a batch of documents, a batch of tickets, a batch of evaluation samples) → batch is a very good fit.
  4. Is the cost of rerunning on failure high? High → real-time for immediate feedback; low → batch retries in bulk are more cost-effective.

Typical batch scenario checklist

  • Content classification and tagging: a unified tagging system for hundreds of thousands of products, reviews, and tickets.
  • Offline data cleaning: extracting unstructured text into structured fields in bulk.
  • Regression evaluation: running a fixed evaluation set for comparison before changing prompts.
  • Bulk summarization / translation: offline organization of document libraries, customer service records, and meeting minutes.
  • Synthetic data generation: generating samples in bulk for training or evaluation.

The pitfalls of batch: partial success and retries

A batch job is not 'all or nothing'. In a job of several hundred requests, a few usually fail due to parameter errors, overly long inputs, content policy, and so on. Engineering must ensure:

  • Record results per item; do not treat the success or failure of the whole batch as a single boolean.
  • Distinguish retryable from non-retryable: 429 / 5xx are retryable; retrying a 400 parameter error is useless.
  • Idempotency keys: resubmitting the same business data must not cause duplicate billing or duplicate writes.
  • Cost rehearsal: estimate an upper bound by tokens before submission to avoid an unexpected bill from a single job.

Manage both channels with one gateway

Splitting real-time and batch into two independent sets of accounts, keys, and bills is the most common architectural debt: when prices change you have to update two places, and troubleshooting failures means digging through two backends.

Admesh's approach is one Base URL, one set of keys, and one bill: on the business side you use task type to decide which channel to use, while the model catalog and unit prices always come from the same backend configuration, so margin and usage are visible in one place.

Актуальные тарифы Admesh (фрагмент)

Цены взяты из текущей конфигурации Admesh, в долларах США за миллион токенов. Полный список — в каталоге моделей.

Прайс-лист моделей Admesh.ai: цены и контекстные окна для 8 доступных моделей
Название и ID моделиКонтекстное окноЦена ввода / 1MЦена вывода / 1MПопадания в кэш / 1 млн
Claude Fable 5anthropic/claude-fable-5
1M$3.8 / 1M$19.00 / 1M$0.38 / 1M
Claude Fable 5.1anthropic/claude-fable-5-1
1M$3.8 / 1M$19.00 / 1M$0.095 / 1M
Claude Fable 5.2anthropic/claude-fable-5-2
—$0.88 / 1M$4.4 / 1M$0.022 / 1M
Claude Haiku 4.5 (latest)anthropic/claude-haiku-4-5
200K$0.11 / 1M$0.55 / 1M$0.011 / 1M
Claude Haiku 4.5anthropic/claude-haiku-4-5-20251001
200K$0.11 / 1M$0.55 / 1M$0.011 / 1M
Claude Haiku 5.5anthropic/claude-haiku-5-5
1M$0.011 / 1M$0.055 / 1M$0.0011 / 1M
Claude Opus 4.5 (latest)anthropic/claude-opus-4-5
200K$0.55 / 1M$2.75 / 1M$0.055 / 1M
Claude Opus 4.5anthropic/claude-opus-4-5-20251101
200K$0.55 / 1M$2.75 / 1M$0.055 / 1M

Выше указаны стандартные цены за единицу для публичных каналов; тарификация выполняется по фактическому расходу токенов. Посмотреть полный каталог моделей

View rate limit and concurrency documentation →

Частые вопросы

How much can batch save?
Batch discounts vary by vendor and model and are adjusted across generations, so hardcoding percentages in an article is not advisable. The right approach is to confirm on the current pricing page, or compare real-time and batch prices directly in the gateway's price list.
How long does a batch job usually take to complete?
It depends on the vendor's queuing policy and job volume, and may range from tens of minutes to over ten hours. The business side should not rely on the assumption that it will 'definitely complete within N hours'; it should be built as an async task with callbacks/polling plus a timeout fallback.
Can the same business mix batch and real-time?
Not only can it, it is recommended. A typical structure is: the user's immediate actions in the interface go through the real-time channel, while background bulk organization, evaluation, and archiving go through the batch channel, with both sharing the same model catalog and price configuration.

Источники

Вызывайте эти модели через один шлюз

Admesh предоставляет единый API, совместимый с OpenAI: один Base URL и один ключ для Claude, GPT, DeepSeek и других моделей. Новым аккаунтам доступен пробный кредит без срока действия.