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

# Error handling

> The exception hierarchy and what each status code means.

All SDK exceptions inherit from `SDVMError`, so one handler catches everything, and the specific classes let you react to the cases that matter.

```python wrap theme={"theme":{"light":"material-theme-lighter","dark":"material-theme-darker"}}
import os

from sdvm import (
    APIError,
    AuthenticationError,
    Fixer,
    InsufficientCreditsError,
    RateLimitError,
)
from sdvm.types import TextSample

try:
    result = Fixer(api_key=os.environ["SDVM_API_KEY"]).run([TextSample(text="hello")])
except AuthenticationError:
    print("Invalid or revoked API key.")
except InsufficientCreditsError:
    print("Not enough credits. Add more at https://sdvm.ai/profile.")
except RateLimitError:
    print("Rate limit hit. Retry in a few seconds.")
except APIError as e:
    print(f"Unexpected error {e.status_code}: {e}")
```

| Exception                  | HTTP      | Meaning                                                                      |
| -------------------------- | --------- | ---------------------------------------------------------------------------- |
| `AuthenticationError`      | 401       | Invalid or revoked API key.                                                  |
| `InsufficientCreditsError` | 402       | The account balance cannot cover the request.                                |
| `RateLimitError`           | 429       | More than 100 requests per minute.                                           |
| `APIError`                 | any other | Unexpected server error; `status_code` and the message are on the exception. |

## Validation errors

The server rejects a request with 422 when a sample is malformed, the list is empty or longer than 100, a sample is larger than the model can hold, or the estimated cost exceeds the per-request limit. These arrive as `APIError` with `status_code == 422` and a message that says what to change.

## Timeouts

Every client takes a `timeout` in seconds (default 120). Large batches take longer; raise it rather than splitting into tiny requests, which only spends the rate limit faster.
