Chat request (Structured outputs)
POST
http://localhost:11434/api/chat
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://localhost:11434/api/chat' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "llama3.1",
"messages": [{"role": "user", "content": "Ollama is 22 years old and busy saving the world. Return a JSON object with the age and availability."}],
"stream": false,
"format": {
"type": "object",
"properties": {
"age": {
"type": "integer"
},
"available": {
"type": "boolean"
}
},
"required": [
"age",
"available"
]
},
"options": {
"temperature": 0
}
}'
Response Response Example
{
"model": "string",
"created_at": "string",
"message": {
"role": "string",
"content": "string"
},
"done_reason": "string",
"done": true,
"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:13:25