Request (Structured outputs)
POST
http://localhost:11434/api/generate
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://localhost:11434/api/generate' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "llama3.1:8b",
"prompt": "Ollama is 22 years old and is busy saving the world. Respond using JSON",
"stream": false,
"format": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"available": {
"type": "boolean"
}
},
"required": [
"age",
"available"
]
}
}'
Response Response Example
{
"model": "string",
"created_at": "string",
"response": "string",
"done": true,
"done_reason": "string",
"context": [
0
],
"total_duration": 0,
"load_duration": 0,
"prompt_eval_count": 0,
"prompt_eval_duration": 0,
"eval_count": 0,
"eval_duration": 0
}
Request
Header Params
Content-Type
string
required
Example:
application/json
Body Params application/json
Responses
Modified at 2025-03-14 08:01:40