> ## 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 API errors

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

Abliteration 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, invalid `tool_choice`, mixed `tools` + `web_search_options` | Check the reported `param` and correct the 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, or an enforcing policy matched | Check the error code before changing the request |
| `429` | Rate limited | Back off, honor `Retry-After` |
| `503` | Service unavailable, including `policy_evaluation_unavailable` | Retry with exponential backoff |
| Other `5xx` | Upstream failure | Retry with exponential backoff |

`GET /v1/credits` can return `503 credit_balance_unavailable`. Honor
`Retry-After` before retrying.

## Policy errors

An enforcing policy match returns `403 policy_violation`. Retrying the same
input with the same policy configuration will produce the same result.

```json theme={"system"}
{
  "error": {
    "type": "policy_error",
    "code": "policy_violation",
    "message": "The request was blocked by a safety policy.",
    "request_id": "req_abc123"
  }
}
```

If a customer Block policy cannot be evaluated before its deadline, the API
withholds the request or buffered response and returns the retryable error
`503 policy_evaluation_unavailable`:

```json theme={"system"}
{
  "error": {
    "type": "policy_error",
    "code": "policy_evaluation_unavailable",
    "message": "A policy could not be evaluated. Retry the request.",
    "request_id": "req_abc123"
  }
}
```

Customer Monitor policy failures do not block delivery. Platform protection
evaluation failures fail open. A confirmed platform or customer Block match
still blocks.

For streaming requests, request-policy errors are returned before the stream
starts. Response-policy errors use the endpoint's native terminal error event:

* Chat Completions emits an OpenAI error data frame and omits `[DONE]`.
* Responses emits `response.failed` and omits `response.completed`.
* Messages emits `event: error` and omits `message_stop`.

Buffered response content and tool calls are not released before response
policy evaluation completes.

## Policy billing

* Requests blocked before model generation are not billed.
* Generated responses withheld by a confirmed response-policy match are billed.
* Responses withheld because a Block policy could not be evaluated are not billed.
* Responses delivered after a Monitor policy evaluation failure are billed normally.


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