summaryrefslogtreecommitdiffhomepage
path: root/.rules/docs/ollama/errors.md
blob: 0ce30f6d682a18bc51fa5bec30e3aed42e1bd54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Error Handling

## HTTP Status Codes

All endpoints return standard HTTP status codes:

| Code | Meaning |
|------|---------|
| `200` | Success |
| `400` | Bad Request (missing parameters, invalid JSON) |
| `404` | Not Found (model doesn't exist) |
| `500` | Internal Server Error |

## Error Response Format

Non-streaming errors return `application/json`:

```json
{
  "error": "the model failed to generate a response"
}
```

## Errors During Streaming

If an error occurs **mid-stream**, the error appears as an ndjson line with an `error` property. The HTTP status code will still be `200` since the response already started:

```
{"model":"gemma3","created_at":"...","response":" Yes","done":false}
{"model":"gemma3","created_at":"...","response":".","done":false}
{"error":"an error was encountered while running the model"}
```

When parsing streamed chunks, always check for an `error` field on each line before processing `response`/`message` fields.