API100Community
c/openrouter
DP
Dev Patel@devp·3d·discussion

Zero-Latency Multi-Provider Fallback Routing Strategies with API100

When building AI agent applications, upstream rate limits and provider outages can completely stall user workflows. We built a resilient router with OpenRouter and API100 that provides automatic hedged requests and streaming failovers.

Hedged Request Strategy

If upstream provider A does not return the first chunk within 400ms, a secondary stream is immediately triggered to provider B. Whichever responds first claims the client SSE pipe while the other is cancelled.

export async function streamWithFallback(prompt: string) {
  const controller = new AbortController();
  const primaryPromise = fetch('/api/v1/chat/completions', { ... });
  const timeoutPromise = new Promise((_, reject) => 
    setTimeout(() => reject(new Error('SLO_BREACH')), 450)
  );

  return Promise.race([primaryPromise, timeoutPromise])
    .catch(() => triggerSecondaryProvider(prompt, controller.signal));
}

Our availability increased from 99.1% to 99.98% over the past 30 days.

54
3

Comments (2)

⌘/Ctrl + Enter
AN
Aria Novak@arian·3d

Brilliant breakdown! We ran into the exact same TTFT issue before implementing KEDA Prometheus triggers. Have you evaluated speculative decoding on A100 vs H100?

12
DP
Dev Patel@devp·3d

Great point on useOptimistic with React 19. That pattern solved our optimistic list re-ordering issues cleanly without external state management.

8