Inference

Published

Serverless AI inference: how it works, what it costs, and when to switch

Summary

Serverless inference means calling a hosted model through an API and paying per token while the provider runs and scales the GPUs. You trade idle cost and capacity planning for variable latency, rate limits under bursts, and the provider's catalog. Switch a workload to dedicated GPUs once a GPU sized for its peak would stay busy about half the day or more.

With serverless AI inference, you send a prompt to a model the provider already runs and get tokens back. The economics come from idle time. A GPU serving one app's traffic sits mostly unused overnight and between bursts, yet it bills for every hour. Serverless lets the provider fill those hours with other customers' requests.

The catch is that the word names two different products. This guide covers how the shared pool works, the control it costs you, and where a dedicated GPU gets cheaper. For what the model does with each request, see how large language models work.

The shared GPU pool

The provider keeps popular models loaded on a large pool of GPUs and routes each request to whichever replica has capacity. Your tokens share decode steps with other customers' tokens, because the serving engine batches every active request on a replica together (the mechanism is in how LLM inference works). The key idea is simple: the provider, not you, keeps the GPU busy. That's why a per-token price can stay low at a volume that would leave your own GPU idle most of the day.

Billing follows from the pooling. Input and output tokens are priced per million at separate rates, and some models bill cached input at a discount. Image models bill per megapixel or per image instead. There's no idle charge and nothing to size. The deployment docs explain the shared pool and per-token billing alongside the other options.

Scaling is invisible from your side. Autoscaling happens across the whole pool, so you never pick a replica count. The ceiling you can hit during large bursts is a rate limit.

Two products, one name

Two different products go by "serverless," and they bill and behave differently:

  • Serverless model APIs: The provider hosts a catalog of models on shared GPUs and bills per token. Cold starts are rare, because popular models stay loaded. This is what most engineers mean by serverless LLM inference.
  • Serverless GPU functions and containers: You bring a container or weights, and the platform starts GPUs on demand, scales to zero when idle, and bills per second or millisecond of compute. Cold starts come with the design, because each new instance has to start a container, download weights, load them into GPU memory, and warm up. Amazon SageMaker Serverless Inference is a scale-to-zero container service of this kind, and according to AWS's documentation it doesn't support GPUs and caps memory at 6 GB.

Which one someone means changes every answer about cold starts and cost, so the rest of this page covers model APIs and notes where functions differ.

What you give up

Four limits come with a shared pool:

  • Latency variance: Performance is best-effort. Together AI's deployment guide says that at peak times, time to first token (TTFT) can run 2–3× the average. Measure P95 at your real prompt lengths, because a mean taken at a quiet hour hides the peaks.
  • Rate limits: When demand spikes, the pool sheds load with 429 (Too Many Requests) and 503 (Service Unavailable) responses. Back off exponentially and spread bursts out. Models in heavy demand can carry their own limits, and committed throughput is a separate, reserved product. See rate limits and 429 handling.
  • Catalog and versions: Your choice is limited to the provider's catalog, and that catalog changes under you. On Together, a same-lineage upgrade takes over the old model ID after 3 days' notice, and a materially new model retires the old one on a 2-week timeline, per the model lifecycle policy. Re-run your evals when a redirect lands (evaluating LLM quality), and use a dedicated endpoint to keep an old version.
  • Custom weights: Fine-tuned models, older model generations, and niche models usually run on dedicated capacity. The pool mostly hosts models with enough demand to keep it full.

Serverless is not a latency guarantee.

Serverless vs. provisioned vs. dedicated

Five options cover most production traffic, and they differ mainly in who pays for idle time and who absorbs cold starts.

OptionBilling unitIdle costCold startsLatencyCustom weightsYou operate
Serverless model APIPer tokenNoneRare (models stay loaded)Best-effort, varies with pool loadUsually not (provider catalog)Nothing
Provisioned throughputReserved tokens per minute, term commitmentYesNot publishedThroughput and reliability under an SLANo (provider's models)Commitment size
Dedicated endpointPer GPU, metered by the minuteYes, unless stoppedWhen replicas are added or restartedPredictable, yours aloneYesSizing and autoscaling policy
Serverless GPU functionsPer second of GPU timeNone at zero replicasYes, on scale from zeroDepends on warm poolYes (your container)Container, weights, warm-up
Self-hosted or dedicated containersPer GPU-hour or owned hardwareYesYours to manageYours to tuneYesThe whole serving stack

You don't have to pick one. A common split is serverless for most traffic plus a small dedicated endpoint for the latency-critical paths, and the deployment docs sketch a dedicated endpoint whose overflow spills onto serverless.

The cost crossover

The guide to how LLM inference works covers per-token vs. per-GPU-hour pricing and the docs' raw-volume crossover, which assumes steady load. You buy dedicated capacity for your peak while serverless bills your average, so the question is how busy a peak-sized GPU stays:

effective dedicated cost per 1M tokens = hourly rate × 1,000,000 ÷ (average tokens/sec × 3,600)

The deployment docs' illustrative inputs are ~\$3 per GPU-hour (see what an H100 costs) and \$1 per 1M tokens on serverless. Neither is a price quote. Assume one GPU serves a 2,000 tokens/sec peak (input plus output, the same tokens the per-token rate counts) at your latency target. That capacity is an assumption, and your model's will differ. At a 4:1 peak-to-average ratio, average load is 500 tokens/sec, or 43.2M tokens a day. Dedicated then costs ~\$1.67 per 1M tokens against \$1 on serverless. At 2:1 (1,000 tokens/sec average), the GPU serves 86.4M tokens a day at ~\$0.83 per 1M, and dedicated wins.

With these inputs, break-even is an average of ~833 tokens/sec, about 42% of the GPU's peak capacity, and it rises ~280 tokens/sec for every extra \$1 per GPU-hour. At a hypothetical \$0.20 per 1M tokens for a small model, it climbs to ~4,170 tokens/sec, about twice the assumed peak, so serverless wins unless one GPU can serve far more than 2,000 tokens/sec.

Autoscaling dedicated endpoints trims idle replicas, but each new replica needs GPU placement, a weight download, and an engine load first, so you still hold headroom for spikes.

Conclusion

Three rules cover most decisions:

  • Begin each new workload on a serverless API, and log P95 latency and daily tokens from day one.
  • Move a path to dedicated capacity when its P95 misses your target, or when its average load would keep a peak-sized GPU more than about half busy.
  • Keep serverless for overflow and the long tail of models you call occasionally.

Together's serverless inference API and dedicated model inference take the same API calls, so moving a path between them comes down to changing the model string.

FAQ

What is inference as a service? Calling models through an API while a provider runs the GPUs. Per-token serverless APIs are its most common form, and provisioned and dedicated endpoints sell the same service on reserved capacity.

Is a serverless model API the same as a serverless GPU? No. A model API serves the provider's hosted models and bills per token. A serverless GPU platform runs your container on GPUs it starts on demand, bills per second, and cold-starts when scaling from zero.

Do serverless LLM APIs have cold starts? Rarely, for hosted models on a shared pool, because popular models stay in GPU memory; cold starts belong to scale-from-zero containers and to dedicated replicas being added or restarted.

Can you run a fine-tuned model on a serverless API? Usually it runs on dedicated capacity, since providers mostly pool models with enough demand to keep the GPUs full. Check which custom models, if any, your provider serves per token.

Why does a serverless API return 429 errors? The provider is protecting shared capacity during a burst. On a 429, slow down and spread requests out. On a 503, wait briefly and retry with exponential backoff. For committed throughput, reserve capacity.

Related articles