> For the complete documentation index, see [llms.txt](https://docs.kontinent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kontinent.ai/documentation/dokumentation/best-practices/retries-and-backoff.md).

# Wiederholungen & Backoff

Kontinent übernimmt das Failover auf Anbieterebene für Sie, aber Ihr Client braucht trotzdem eine vernünftige Retry-Strategie für die Fehler, die bei ihm ankommen.

## Nach Statuscode entscheiden

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><h4><i class="fa-rotate" style="color:$primary;">:rotate:</i></h4></td><td><strong>Wiederholbar</strong></td><td><code>429</code>, <code>500</code>, <code>502 upstream_error</code>. Nutzen Sie exponentiellen Backoff mit Jitter.</td></tr><tr><td><h4><i class="fa-ban" style="color:$primary;">:ban:</i></h4></td><td><strong>So nicht wiederholbar</strong></td><td><code>400</code>, <code>401</code>, <code>403</code>, <code>404</code>. Beheben Sie zuerst die Anfrage oder den Schlüssel.</td></tr></tbody></table>

* `401 invalid_api_key`: der Schlüssel ist falsch oder widerrufen. Ein erneuter Versuch mit demselben Schlüssel hilft nicht.
* `402 insufficient_credits`: erst nach einer Aufladung wiederholbar.
* `403 segment_not_permitted`: wählen Sie ein Modell eines anderen Anbieters, statt es erneut zu versuchen.
* `429 rate_limit_exceeded`: das RPM-Fenster Ihres Schlüssels ist voll. Warten Sie mindestens das 60-s-Fenster ab.
* `429 upstream_rate_limited`: der Anbieter hat gedrosselt, nicht Sie. Mit Backoff erneut versuchen.

Die vollständige [Fehler-Taxonomie](/documentation/dokumentation/features/errors.md) finden Sie mit allen Codes.

## Streaming braucht eine andere Regel

Failover zwischen Anbietern passiert nur **vor dem ersten Byte** eines Streams. Sobald Tokens eintreffen, sieht ein Anbieterfehler wie eine abgebrochene Verbindung aus, nicht wie ein sauberer HTTP-Fehler. Behandeln Sie einen Stream, der ohne `data: [DONE]` endet, als wiederholbaren Fehler auf Ihrer Seite, und denken Sie daran, dass die bis dahin generierten Tokens bereits abgerechnet sind. Siehe [Streaming](/documentation/dokumentation/features/streaming.md).

## Eine vernünftige Grundeinstellung

Für die meisten Clients funktioniert exponentieller Backoff mit Jitter gut, beginnend bei etwa 200 bis 500 ms und gedeckelt auf wenige Sekunden, sowohl für `429`-Fälle als auch für vorübergehende `5xx`-Fehler. Stoppen Sie nach einer kleinen, festen Anzahl von Versuchen und melden Sie den Fehler; versuchen Sie es nicht unbegrenzt weiter.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kontinent.ai/documentation/dokumentation/best-practices/retries-and-backoff.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
