retries.md
Retries
Configure retries with RetryPolicy — attempt count, retryable statuses, backoff, and retry headers handling.
export function SdkSignature({children}) {
async function copy(event) {
const button = event.currentTarget;
const code = button.parentElement.querySelector("pre code");
try {
await navigator.clipboard.writeText(code.textContent);
button.setAttribute("aria-label", "Signature copied");
button.dataset.copied = "true";
} catch {
button.setAttribute("aria-label", "Copy failed; select the signature to copy");
}
setTimeout(() => {
button.setAttribute("aria-label", "Copy signature");
delete button.dataset.copied;
}, 2000);
}
return <div className="sdk-signature not-prose">
<button type="button" className="sdk-signature-copy" aria-label="Copy signature" onClick={copy}>
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5">
<rect x="8" y="8" width="12" height="12" rx="2" />
<path d="M16 8V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h3" />
</svg>
</button>
<pre tabIndex={0} aria-label="SDK signature"><code>{children}</code></pre>
</div>;
}
typesafe_sdk.RetryPolicy
max_retries
Maximum retries after the initial attempt; 0 disables retries.
backoff_initial
First backoff delay in seconds, doubled each attempt up to backoff_max; zero disables backoff.
backoff_max
Maximum backoff delay in seconds; zero disables backoff.
backoff_jitter
Fraction of each backoff delay randomly subtracted, between 0 and 1.
http_statuses
HTTP status codes that are retried.
respect_retry_after
Whether to honor Retry-After and retry-after-ms response headers.
api_connection_error
Whether to retry TypeSafeAPIConnectionError, raised when the request cannot reach or read from the server.
api_timeout_error
Whether to retry TypeSafeAPITimeoutError, raised when the request exceeds its timeout.
exceptions
Additional exception types that trigger a retry, on top of the built-in rules.
predicate
An optional predicate called with the raised exception; returning True triggers a retry in addition to the other rules.
timeout
Total retry budget in seconds per SDK call, including the initial attempt and delays; None disables the limit.
Stops before a retry whose delay would reach or exceed the budget, re-raising the last error.