---
title: "Keep working when the AI provider fails · Agent Wranglers"
url: https://agentwranglers.se/playbook/operations/disaster-recovery/model-provider-failure
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep working when the AI provider fails

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Disaster recovery](https://agentwranglers.se/playbook/operations/disaster-recovery)
- Rule: Decide what an AI feature does when the model provider is slow, down or out of quota. Show a clear message, never a hang or a broken page.
- How: Set a timeout on every model call, as the [timeouts rule](https://agentwranglers.se/playbook/api-design/reliability/timeouts) asks, and retry at most once with backoff. Fall back to a second model or provider, a simpler non-AI path, or a message that says the feature is paused. Alert when the error rate rises, and keep the rest of the product working.
- Check: Block the provider's address on staging. The feature answers within its timeout with the fallback or the message, and the rest of the site works.

Example:

```js
const MODEL_TIMEOUT_MS = 10_000;

async function summarize(text) {
  try {
    const res = await fetch('https://models.example.com/v1/generate', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ model: settings.model, input: text }),
      signal: AbortSignal.timeout(MODEL_TIMEOUT_MS),
    });
    if (!res.ok) throw new Error(`model answered ${res.status}`);
    return { summary: (await res.json()).output };
  } catch (error) {
    log.warn({ event: 'model.unavailable', error: error.message });
    return { summary: null, notice: 'Summaries are paused. Your document is saved.' };
  }
}
```

```python
import httpx

MODEL_TIMEOUT_SECONDS = 10

def summarize(text):
    try:
        response = httpx.post("https://models.example.com/v1/generate",
                              json={"model": settings.model, "input": text}, timeout=MODEL_TIMEOUT_SECONDS)
        response.raise_for_status()
        return {"summary": response.json()["output"]}
    except httpx.HTTPError as error:
        log.warning("model.unavailable", error=str(error))
        return {"summary": None, "notice": "Summaries are paused. Your document is saved."}
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers operations playbook: https://agentwranglers.se/playbook/operations/disaster-recovery/model-provider-failure`.

- Previous: [Plan for losing a provider](https://agentwranglers.se/playbook/operations/disaster-recovery/provider-failure)
- [Disaster recovery](https://agentwranglers.se/playbook/operations/disaster-recovery)
