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

# Errors and retries

> Read a failed request and retry the same submission.

HTTP failures raise `APIStatusError` with `status_code`, `code`, `message`, and `request_id`. Network failures raise `APIConnectionError`.

```python theme={null}
from trajectory import APIConnectionError, APIStatusError, Client

client = Client()
try:
    benchmark = client.benchmarks.retrieve("YOUR_BENCHMARK_ID")
except APIStatusError as error:
    print(error.status_code, error.code, error.message)
    print(error.request_id)
except APIConnectionError as error:
    print(error)
else:
    print(benchmark.model_dump())
```

The client retries connection failures, timeouts, `408`, `429`, and `5xx` twice. Set `max_retries=0` to turn that off.
When adapting a harness that handles its own retries, preserve the SDK error's status,
headers, and body. In particular, pass through `Trajectory-Should-Retry: false` so the harness
does not retry an attempt the service has already rejected.

Spec (benchmark) uploads retry longer, to ride out signing throttling: `push()` and `start_push()` retry each upload request up to `upload_max_retries` times (default `32`) or for 4.5 minutes of waiting, whichever comes first. The client's `max_retries` does not apply to them. Pass `upload_max_retries=0` to turn that off.

Reuse an `idempotency_key` only when repeating the same submission. A new evaluation or training run needs a new key.

Errors inside a trajectory, such as a model request your harness cannot recover from, are
reported through the trajectory's termination reason. See [Termination reasons](https://docs.trajectory.ai/guides/termination-reasons.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.