mirror of
https://github.com/ollama/ollama.git
synced 2026-10-20 18:41:17 +00:00
docs: document API error response format
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d126467d5d
commit
f87f9af277
1 changed files with 41 additions and 0 deletions
41
docs/api.md
41
docs/api.md
|
|
@ -32,6 +32,47 @@ All durations are returned in nanoseconds.
|
|||
|
||||
Certain endpoints stream responses as JSON objects. Streaming can be disabled by providing `{"stream": false}` for these endpoints.
|
||||
|
||||
### Error responses
|
||||
|
||||
If a request fails, the API returns an appropriate HTTP status code along with a JSON object containing an `error` field with a description of the issue:
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "model 'nomodel' not found"
|
||||
}
|
||||
```
|
||||
|
||||
Common HTTP status codes:
|
||||
|
||||
| Status Code | Description |
|
||||
|-------------|-------------|
|
||||
| 400 | Bad request - the request body is invalid or missing required fields |
|
||||
| 404 | Not found - the requested model does not exist |
|
||||
| 500 | Internal server error - an unexpected error occurred on the server |
|
||||
|
||||
#### Example
|
||||
|
||||
##### Request
|
||||
|
||||
```shell
|
||||
curl http://localhost:11434/api/generate -d '{
|
||||
"model": "nomodel",
|
||||
"prompt": "Hello"
|
||||
}'
|
||||
```
|
||||
|
||||
##### Response
|
||||
|
||||
```
|
||||
HTTP/1.1 404 Not Found
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"error": "model 'nomodel' not found"
|
||||
}
|
||||
```
|
||||
|
||||
## Generate a completion
|
||||
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue