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

# Error events

> Failures mid-stream and before the first byte.

## Mid-Stream

If generation fails after the stream has begun, a chunk carries a top-level `error` and a terminal choice:

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "id": "...",
  "object": "chat.completion.chunk",
  "created": 1751299200,
  "model": "z-ai/glm-5.2",
  "error": { "message": "human-readable description", "code": "provider_error", "param": null },
  "choices": [
    { "index": 0, "delta": {}, "finish_reason": "error" }
  ]
}
```

| Field | Notes |
| - | - |
| `error.message` | Human-readable description. |
| `error.code` | The error family. Same families as the [error format](/api/api-reference/overview/error-format). |
| `error.param` | Optional. The field the error refers to, when applicable. |
| `choices[0].finish_reason` | `error`. See [Finish reasons](/api/api-reference/chat-and-text/finish-reasons). |

Content streamed before this chunk is partial. The stream still ends with `[DONE]`.

## Before the First Byte

A request rejected before any byte is written (auth, validation, limits, a provider that never opened) returns a normal HTTP error with the standard envelope. See [Error format](/api/api-reference/overview/error-format).

A streaming client therefore handles two shapes: a non-`200` response with a JSON body, and a `200` stream that later carries an error chunk.

## Related

* [Error format](/api/api-reference/overview/error-format)
* [Finish reasons](/api/api-reference/chat-and-text/finish-reasons)
* [Delta format](/api/api-reference/streaming-format/delta-format)
* [Stream termination](/api/api-reference/streaming-format/stream-termination)


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