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

# Error Codes

## Error Event Format

Errors arrive as SSE events:

```text theme={null}
event: error
data: {"error":"Invalid configuration","code":"VALIDATION_ERROR","retryable":false}
```

```typescript theme={null}
interface ErrorEvent {
  error: string;
  code?: string;
  retryable?: boolean;
}
```

***

## Error Codes

| Code                   | HTTP Status | Retryable | Description                        |
| ---------------------- | ----------- | --------- | ---------------------------------- |
| `VALIDATION_ERROR`     | 400         | No        | Invalid request body or parameters |
| `AUTHENTICATION_ERROR` | 401         | No        | Invalid or missing API key         |
| `RATE_LIMIT_ERROR`     | 429         | Yes       | Too many requests                  |
| `PROCESSING_ERROR`     | 500         | Yes       | Internal processing failure        |
| `TIMEOUT_ERROR`        | 504         | Yes       | Request took too long              |

***

## Common Errors

### VALIDATION\_ERROR

Missing required fields (`config`, `userPrompt`), invalid `GraphConfig` structure, or malformed JSON.

**Resolution:** Check the request body against the schema.

### AUTHENTICATION\_ERROR

Missing `Authorization` header, malformed header (missing `Bearer ` prefix), or invalid API key.

**Resolution:** Verify the API key and header format.

### RATE\_LIMIT\_ERROR

Too many requests in a short period.

**Resolution:** Implement exponential backoff and retry.

### PROCESSING\_ERROR / TIMEOUT\_ERROR

Internal failure or request took too long.

**Resolution:** Retry with exponential backoff. If persistent, contact support.

***

## HTTP Status Codes

Errors may also arrive as HTTP status codes before streaming begins:

| Status | Description                                  |
| ------ | -------------------------------------------- |
| 400    | Bad Request — Invalid JSON or missing fields |
| 401    | Unauthorized — Invalid or missing API key    |
| 429    | Too Many Requests — Rate limit exceeded      |
| 500    | Internal Server Error — Processing failure   |
| 504    | Gateway Timeout — Upstream timeout           |

***

## Retry Strategy

For retryable errors, use exponential backoff:

```
delay = base_delay * (backoff ^ attempt)
```

**Recommended defaults:**

* `base_delay`: 1000ms
* `backoff`: 2
* `max_attempts`: 3

| Attempt | Delay           |
| ------- | --------------- |
| 1       | 0ms (immediate) |
| 2       | 1000ms          |
| 3       | 2000ms          |

**Best practices:**

* Only retry if `retryable: true`
* Set a maximum retry count
* Treat network failures as retryable
* The API is stateless, so retries are safe
