Three Technical Paths When Your LLM Service Is Unavailable

    This article explains how to diagnose why a large language model service becomes unavailable and compares three technical responses: adjusting how you call the official service, routing requests through a self-built gateway, and deploying open-source models locally or in a private environment. It covers the difference between capacity, quota, and billing failures, retryable versus non-retryable error handling, gateway features such as semantic caching and multi-level fallback, and the hardware and inference trade-offs of self-hosting. A short decision checklist helps you pick the most economical path before an outage happens.

    1. Diagnose First: Capacity, Quota, and Billing Are Three Different Failures

    When a team hits “I can’t get a response,” the first instinct is often to switch accounts or change networks. That is a misreading of the failure model. Reduced availability of a large language model service usually breaks down into three layers:

    • Capacity layer: the concurrency slots on the inference cluster are fully occupied, requests queue and time out, and users see intermittent “busy” responses. This is a server-side load problem that no client-side retry strategy can truly fix.
    • Quota layer: the account or key is bound to limits such as requests per minute, tokens per minute, or a daily call allowance. The symptom is a stable, reproducible “too frequent” error.
    • Billing layer: the balance is exhausted or the quota cycle has ended. The symptom is a persistent rejection, with error semantics different from the other two.

    In practice, read the returned status code and error body first, and separate “retryable” from “non-retryable.” A sketch of the classification logic:

    1. RETRYABLE = {429, 500, 502, 503, 504}
    2. def classify(err):
    3. if err.status in RETRYABLE:
    4. return "retry" # capacity or transient failure
    5. if err.status == 402:
    6. return "billing" # requires manual intervention
    7. return "fatal" # parameter, auth, and similar errors

    Only once failures are classified does the choice among the three paths below have a solid basis.

    2. Path One: Keep Using the Official Service and Fix How You Call It

    For everyday Q&A, writing and polishing, translation, knowledge organization, and ad hoc code snippets, the official entry point is still the lowest-cost option. What needs improvement is not the entry point but the way you use it:

    1. Compress the context. Split long documents into sections and summarize before asking. This significantly reduces the token volume of each request, which in turn lowers the chance of queuing and rate limiting.
    2. Control concurrency. Set up a semaphore or token bucket on the client side and keep concurrency within what the quota allows. This works far better than blind retries.
    3. Retry with exponential backoff. On retryable errors, increase the wait as 1s, 2s, 4s, and add random jitter so that requests are not all resent at the same moment, which would create a second wave of load.
    1. import random, time
    2. def call_with_backoff(fn, max_retry=5):
    3. for i in range(max_retry):
    4. try:
    5. return fn()
    6. except RetryableError:
    7. time.sleep((2 ** i) + random.random())
    8. raise RuntimeError("exceeded retry budget")

    One common misunderstanding needs clearing up: the web chat entry point and the API entry point are two independent channels, and their rate limiting and quota policies are not shared. A limit on the web side does not mean the API is unavailable, and a quota response from the API does not mean the web side is necessarily healthy. Likewise, registering a new account or frequently switching network egress points cannot change the total capacity constraint on the server side; it only adds complexity on the client side.

    3. Path Two: Build Your Own Client on the API and Own the Experience

    If the team already has a frontend application, an intelligent customer service system, a knowledge base Q&A feature, or an AI coding tool, the more sensible move is to abstract model capability into an internal gateway that handles authentication, rate limiting, caching, and fallback in one place.

    The gateway layer should have at least four capabilities:

    • Unified abstraction: define vendor-agnostic request and response models so the backend can be swapped later without touching business code.
    • Semantic caching: cache results for high-frequency repeated questions to cut call volume directly. This is the most effective single step in cost optimization.
    • Multi-level fallback: when the primary channel is unavailable, switch in turn to a backup channel, a smaller model, a retrieval-based answer, and only then to a canned fallback response.
    • Observability: collect success rate, time to first token, and token consumption through logging and monitoring with alerts, forming a capacity early-warning signal.

    A sketch of the routing skeleton:

    1. def route(req):
    2. if cache.hit(req):
    3. return cache.get(req)
    4. for backend in [primary, secondary, small_model]:
    5. if backend.healthy():
    6. return backend.invoke(req)
    7. return fallback_answer(req)

    The value of this path is that capacity fluctuations are absorbed inside the gateway and the business side does not have to be aware of them. The cost reduction from caching and fallback is also sustainable rather than a one-off workaround.

    4. Path Three: Deploy Open-Source Models Locally or in a Private Environment

    When data cannot leave its domain, when stable offline capability is required, or when call volume has grown large enough that self-hosting is cheaper, self-hosted inference becomes the inevitable choice. Deployment of open-source large models centers on hardware and inference configuration:

    • VRAM estimation: VRAM requirements are roughly determined by parameter count and quantization precision together. Quantization is the main way to lower the entry barrier, but it brings some loss of accuracy that needs to be validated on an evaluation set.
    • Throughput versus latency trade-off: raising batch size improves throughput but increases per-request latency. Interactive scenarios should prioritize time to first token.
    • Service packaging: run the inference service on a container platform, put a load balancer in front, and add elastic scaling to handle peaks.
    • Operational tooling: model versions, prompt templates, and evaluation results should all be under version control, so you never end up “changed the prompt but can’t explain the difference in output.”

    The costs of self-hosting are equally clear: hardware purchase or rental, operations headcount, and keeping up with model updates are all ongoing investments. It is therefore better suited as a supplement to the primary path than as the default option.

    5. How to Combine the Three Paths

    The most robust structure in practice is layered: use the official or cloud-hosted service as the primary channel, use a self-built gateway for routing, caching, and fallback, and use locally deployed models as the last resort in extreme cases. Baidu AI Cloud provides full support across general capabilities such as hosted model services, container platforms, logging, and monitoring with alerts, which makes it easier for teams to implement the layering described above.

    Three questions are enough for a quick decision: can the data leave its domain, is the average daily call volume stable and predictable, and does the team have inference operations capability. The answers point you straight to the most economical path, instead of trial and error in the middle of an outage.