> ## Documentation Index
> Fetch the complete documentation index at: https://docs.physionlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Handle errors and retries

> Recover from API, network, and evaluation failures.

Use the HTTP status and structured error body to choose a recovery path.

| Condition                  | Action                                                                           |
| -------------------------- | -------------------------------------------------------------------------------- |
| `400` invalid request      | Fix the request before retrying.                                                 |
| `401` authentication error | Check the API key and environment.                                               |
| `402` insufficient credits | Add credits or reduce usage.                                                     |
| `404` missing resource     | Check the ID and account ownership.                                              |
| `429` rate limit           | Wait for `Retry-After`, then retry.                                              |
| `5xx` server error         | The SDK retries safe requests with exponential backoff and jitter.               |
| Evaluation status `failed` | Read `evaluation.error`, then call the evaluation retry method when appropriate. |

API errors include a `request_id`. Include it in support requests.

The SDK sends `evaluations.create()` once. After a connection error or `5xx`, the outcome may already exist, and a second submission creates a separate charge. Retrieval, listing, and the idempotent evaluation retry endpoint use bounded automatic retries.

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { GalileoError, RateLimitError } from "@physionlabs/galileo";

    try {
      await galileo.account.retrieve();
    } catch (error) {
      if (error instanceof RateLimitError) {
        console.error("Rate limited", error.retryAfterMs);
      } else if (error instanceof GalileoError) {
        console.error(error.message);
      }
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from physionlabs import GalileoError, RateLimitError

    try:
        galileo.account.retrieve()
    except RateLimitError as error:
        print("Rate limited", error.retry_after)
    except GalileoError as error:
        print(error)
    ```
  </Tab>
</Tabs>
