## Error Code Reference

This page provides a comprehensive reference for all error codes, HTTP status codes, and error handling patterns used across Writer APIs.

### Authentication Issues

**401 Unauthorized**: check your API key format and permissions

### Bad Request Data

**400 + validation_error**: verify required fields and data types

### Rate Limiting

**429 Too Many Requests**: implement exponential backoff

### Server Problems

**5xx Errors**: check our status page or retry your request

### Error Response Format

All API endpoints return errors in a consistent JSON format:

```json
{
  "tpe": "error_type",
  "errors": [
    {
      "description": "Human-readable error description",
      "key": "error.message.key",
      "extras": {}
    }
  ],
  "extras": {}
}
```

### Response Structure

🔧 Core fields (always present)

| Field | Type | Description |
| --- | --- | --- |
| `tpe` | string | Error type identifier (for example, “BadRequest”, “Unauthorized”) |
| `errors` | array | Array of error messages with details |
| `extras` | object | Additional error context and metadata |

### HTTP Status Codes

Writer APIs use standard HTTP status codes to indicate the nature of errors:

| Status | Error code | Type | Description | Common causes |
| --- | --- | --- | --- | --- |
| 400 | `BadRequest` | Validation | Invalid request parameters or malformed request body | Missing required fields, invalid format |
| 401 | `Unauthorized` | Authentication | Missing or invalid authentication credentials | Missing API key, invalid format |
| 403 | `Forbidden` | Authorization | Valid credentials but insufficient permissions | Insufficient access rights |
| 404 | `NotFound` | Validation | Requested resource does not exist | Invalid resource ID, deleted resource |
| 409 | `Conflict` | Validation | Request conflicts with current state | Duplicate resource, version conflict |
| 410 | `Gone` | Validation | Resource was permanently removed | Deleted/expired resource |
| 413 | `PayloadTooLarge` | Validation | Request body too large | Exceeds configured size limits |
| 422 | `UnprocessableEntity` | Validation | Semantically invalid request | Fails business rules/constraints |
| 429 | `TooManyRequests` | Rate Limiting | Rate limit or quota exceeded | Too many requests per time period |
| 500 | `InternalServerError` | Server | Internal server error | Server-side processing issue |
| 503 | `ServiceUnavailable` | Server | Service temporarily unavailable | Maintenance, high load |
| 507 | `InsufficientStorage` | Server | Insufficient storage to complete request | Storage quota exhausted |

### Error Codes by Service

This section provides a comprehensive reference of all possible error codes organized by service and endpoint.

#### Chat Completions API

**Endpoint:** `POST /v1/completion`

| Error Type | HTTP Status | Description | Possible Causes |
| --- | --- | --- | --- |
| `BadRequest` | 400 | Invalid model parameter | Model name not supported or malformed |
| `InvalidInputParameters` | 400 | Invalid prompt format | Empty prompt or invalid encoding |
| `InvalidContentType` | 400 | Invalid parameters | Invalid `temperature`, `max_tokens`, or other parameters |
| `BadCredentials` | 401 | Invalid API key | Missing or malformed API key |
| `BadToken` | 401 | API key expired | API key has expired |
| `InsufficientAccessRights` | 403 | Insufficient permissions | API key lacks required permissions |
| `QuotaExceeded` | 429 | Rate limit exceeded | Too many requests per minute |
| `CompletionModelQuotaError` | 429 | Quota exceeded | Monthly usage limit reached |
| `CompletionModelUnavailableError` | 500 | Model unavailable | AI model temporarily unavailable |
| `CompletionModelInternalError` | 500 | Service overloaded | High load, retry with backoff |

### Guardrail Errors

Guardrail errors occur when content is blocked by configured safety controls.

| Error Type | HTTP Status | Description | Possible Causes |
| --- | --- | --- | --- |
| `GuardrailBlockedError` | 400 | Content blocked by guardrail | Input or output violated guardrail policy |
| `BadRequest` | 400 | Bedrock guardrail violation | Content blocked by AWS Bedrock guardrail policy |
| `BadRequest` | 400 | Azure Content Safety violation | Content blocked by Azure text moderation or Prompt Shields |
| `BadCredentials` | 401 | Guardrail authentication failed | Invalid AWS credentials for Bedrock guardrail |
| `InsufficientAccessRights` | 403 | Guardrail access denied | Missing permissions for guardrail provider |
| `ResourceNotFound` | 404 | Guardrail not found | Invalid guardrail ID or version |
| `InternalError` | 500 | Guardrail processing error | Error communicating with guardrail provider |
| `InternalError` | 503 | Guardrail service unavailable | Guardrail provider service is down |

### Troubleshooting Common Errors

#### 400 Bad Request
- Verify all required parameters are included
- Check parameter value formats and constraints
- Ensure request body is valid JSON

#### 401 Unauthorized
- Verify API key is correct and not expired
- Check that the API key has the required permissions
- Ensure the Authorization header is properly formatted

#### 403 Forbidden
- Check if your organization/team has access to the requested resource
- Verify that the feature is enabled for your plan
- Contact support if you believe this is an error

#### 429 Too Many Requests
- Implement exponential backoff retry logic
- Check your current usage against rate limits
- Consider upgrading your plan for higher limits
