Generate a chat message
Generate the next chat message in a conversation between a user and an assistant.
curl http://localhost:11434/api/chat -d '{
"model": "gemma4",
"messages": [
{
"role": "user",
"content": "why is the sky blue?"
}
]
}'{
"model": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"message": {
"role": "assistant",
"content": "<string>",
"thinking": "<string>",
"tool_calls": [
{
"function": {
"name": "<string>",
"description": "<string>",
"arguments": {}
}
}
],
"images": [
"<string>"
]
},
"done": true,
"done_reason": "<string>",
"total_duration": 123,
"load_duration": 123,
"prompt_eval_count": 123,
"prompt_eval_duration": 123,
"eval_count": 123,
"eval_duration": 123,
"logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}Body
Model name
Chat history as an array of message objects (each with a role and content)
Show child attributes
Show child attributes
Optional list of function tools the model may call during the chat
Show child attributes
Show child attributes
Format to return a response in. Can be json or a JSON schema
json Runtime options that control text generation
Show child attributes
Show child attributes
When true, returns separate thinking output in addition to content. Can be a boolean (true/false) or a string ("high", "medium", "low") for supported models.
Model keep-alive duration (for example 5m or 0 to unload immediately)
Whether to return log probabilities of the output tokens
Number of most likely tokens to return at each token position when logprobs are enabled
Response
Chat response
Model name used to generate this message
Timestamp of response creation (ISO 8601)
Show child attributes
Show child attributes
Indicates whether the chat response has finished
Reason the response finished
Total time spent generating in nanoseconds
Time spent loading the model in nanoseconds
Number of tokens in the prompt
Time spent evaluating the prompt in nanoseconds
Number of tokens generated in the response
Time spent generating tokens in nanoseconds
Log probability information for the generated tokens when logprobs are enabled
Show child attributes
Show child attributes
curl http://localhost:11434/api/chat -d '{
"model": "gemma4",
"messages": [
{
"role": "user",
"content": "why is the sky blue?"
}
]
}'{
"model": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"message": {
"role": "assistant",
"content": "<string>",
"thinking": "<string>",
"tool_calls": [
{
"function": {
"name": "<string>",
"description": "<string>",
"arguments": {}
}
}
],
"images": [
"<string>"
]
},
"done": true,
"done_reason": "<string>",
"total_duration": 123,
"load_duration": 123,
"prompt_eval_count": 123,
"prompt_eval_duration": 123,
"eval_count": 123,
"eval_duration": 123,
"logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
],
"top_logprobs": [
{
"token": "<string>",
"logprob": 123,
"bytes": [
123
]
}
]
}
]
}