infrastructure

Routing & Fallback

How LW AI routes requests and handles automatic fallback for high availability.

LW AI uses intelligent routing and automatic fallback mechanisms to ensure high availability and optimal performance for every request.

Request Routing

Region-Based Routing

All requests use the single endpoint https://api.atrouter.cn. GeoDNS routes each request to the nearest region automatically:

  • Mainland China users → Beijing cluster (lowest latency)
  • Other international users → Singapore infrastructure

Model Routing (Astra V1 Pro)

When using the fusion model, requests are routed to the best underlying model based on:

FactorDescription
Task complexitySimple → Flash, Complex → Pro
DomainFinance/energy → Yantronic V1 Pro
LanguageChinese → GLM, English/Code → DeepSeek
Current loadBalances across models for throughput

Automatic Fallback

If the primary model or infrastructure is unavailable, LW AI automatically falls back to maintain service:

Model Fallback

Primary Model → Fallback Model (same capability tier)

For example, if deepseek/deepseek-v4-pro is overloaded:

  1. Request routed to deepseek/deepseek-v4-pro
  2. If unavailable, falls back to z-ai/glm-5.1 (same tier)
  3. Response returned with model_routed header indicating the actual model used

Infrastructure Fallback

Primary Region → Secondary Region

If the Beijing region experiences issues:

  1. Requests to https://api.atrouter.cn fail over inside the domestic cluster
  2. Latency may increase slightly
  3. Service remains available

Fallback Behavior

ScenarioBehaviorUser Impact
Model overloadedFallback to equivalent modelMinimal — same quality tier
Model offlineFallback to equivalent modelMinimal — response includes actual model used
Region degradedCross-region proxySlight latency increase
Complete outageMaintenance pageAPI returns 503 with retry-after header

Disabling Fallback

For applications that require strict model control, you can disable fallback:

response = client.chat.completions.create(
    model="deepseek/deepseek-v4-pro",
    messages=[...],
    extra_body={"allow_fallback": False}
)

When fallback is disabled, unavailable models will return a 503 Service Unavailable error instead of routing to an alternative.

Monitoring

  • Check model_routed in response headers to see which model actually handled your request
  • Use Service Status for real-time infrastructure health