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

# abliteration.ai API errors

> HTTP error codes, error body shapes (OpenAI and Anthropic), and how to handle policy-blocked requests.

abliteration.ai returns HTTP status codes with an error body that matches the upstream API's shape — OpenAI shape on `/v1/chat/completions` and `/v1/responses`, Anthropic shape on `/v1/messages`.

## OpenAI shape

```json theme={"system"}
{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}
```

## Anthropic shape

```json theme={"system"}
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "Invalid API key",
    "code": "invalid_api_key"
  }
}
```

## Anthropic streaming error frame

When a stream fails mid-flight, the server emits an `event: error` SSE frame:

```http theme={"system"}
event: error
data: {"type": "error", "error": {"type": "api_error", "message": "..."}}
```

The stream then closes. Accumulate content defensively — a partial response is valid.

## Status codes

| Status | Cause                                                                         | Fix                                                      |
| ------ | ----------------------------------------------------------------------------- | -------------------------------------------------------- |
| `400`  | Invalid request body, unsupported model, mixed `tools` + `web_search_options` | Check request shape                                      |
| `401`  | Missing or invalid API key                                                    | Send `Authorization: Bearer $ABLIT_KEY`                  |
| `402`  | Insufficient credits                                                          | Top up in the [console](https://abliteration.ai/console) |
| `403`  | Key lacks permission for this project                                         | Scope check in the console                               |
| `429`  | Rate limited                                                                  | Back off, honor `Retry-After`                            |
| `5xx`  | Upstream failure                                                              | Retry with exponential backoff                           |

## Policy-blocked requests

On `/policy/*` endpoints, a policy decision rides alongside the normal response. When `enforcement_action: block` fires in `enforced` mode, the status is `4xx` and the body includes the upstream-shape error plus a `policy` object describing the decision. When the action is `rewrite` or `summarize` (decision `rewrite` / `summary`), the status stays `200` but the content is modified. See [policy endpoints](/api/policy-endpoints) and [streaming policy metadata](/capabilities/streaming-policy-metadata).
