moeru-ai/airi · error · ApiError

GATEWAY_TIMEOUT/SERVICE_UNAVAILABLE/BAD_GATEWAY

GATEWAY_TIMEOUT/SERVICE_UNAVAILABLE/BAD_GATEWAY

Error message

Upstream timeout | Upstream rate-limited | Upstream unavailable (selected by last upstream status: 'timeout'->'Upstream timeout', 429->'Upstream rate-limited', other non-2xx->'Upstream unavailable')

What it means

Error "Upstream timeout | Upstream rate-limited | Upstream unavailable (selected by last upstream status: 'timeout'->'Upstream timeout', 429->'Upstream rate-limited', other non-2xx->'Upstream unavailable')" thrown in moeru-ai/airi.

Source

Thrown at server/apps/api/src/services/domain/llm-router/router.ts:549

    const distinctStatuses = new Set(allFailures.map(f => f.status))
    if (distinctStatuses.size === 1) {
      const status = allFailures[0].status
      // Increment per-provider so multi-upstream models still get one
      // signal per provider involved — operators can see *which* provider
      // ran the shared-backend cap.
      const providersHit = new Set(allFailures.map(f => f.provider))
      for (const provider of providersHit) {
        options.gatewayMetrics?.sameStatusExhaustion.add(1, {
          provider,
          status_code: typeof status === 'number' ? status : 'timeout',
        })
      }
    }

    if (terminalResponse != null)
      return terminalResponse

    throw mapUpstreamError(
      lastFailure.status,
      {
        triedKeys: allFailures.length,
        triedUpstreams,
        lastStatusCode: lastFailure.status,
      },
      allFailures.map(toDiagnosticAttempt),
    )
  }

  /**
   * Run one TTS upstream's key list in order, parallel to {@link dispatchOneUpstream}
   * but delegating actual HTTP to the provider adapter. Adapters surface
   * upstream non-2xx as {@link TtsUpstreamResponseError}; network failures
   * and timeouts arrive as errors without an upstream response.
   */
  async function dispatchOneTtsUpstream(
    upstream: TtsUpstream,

View on GitHub (pinned to f679616c34)

Solutions

  1. Restore or add healthy upstream providers for the model — every candidate was tried and exhausted
  2. For 429 endings, back off and retry after the provider's rate-limit window resets
  3. For timeout endings, review per-upstream timeout settings and provider health before retrying
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at server/apps/api/src/services/domain/llm-router/router.ts:549 when the library encounters an invalid state.

Common situations: See trigger scenarios.

Understand the failure class


AI-assisted analysis of moeru-ai/airi@f679616c34 (2026-09-08). Data as JSON: /api/errors/5f93e53bda3d6417. Report an issue: GitHub.