Some jobs need one answer, not a conversation: summarise a paragraph, finish a line of code, or answer a single question from a script. Ollama’s /api/generate endpoint is built for that. The API reference says it generates “a response for a given prompt with a provided model”, and takes a model and a prompt. Its sibling, /api/chat, takes a messages array instead, because it keeps a conversation going. Pick generate when there is no history to keep.
/api/generate or /api/chat: pick by whether you need history
The two endpoints look similar, but they answer different questions. Serverman’s REST API guide puts it plainly: generate “is the simplest way to get a response from a model”, while chat “uses a messages array” so each turn can build on the last one.
| Endpoint | What you send | What you get back |
|---|---|---|
/api/generate |
One prompt string |
The text in the response field |
/api/chat |
A messages array with roles |
The reply in message.content |
Try it: ask one question with streaming off
Send the request below with curl. It is the API reference’s own example: model llama3.2 and the prompt “Why is the sky blue?”, with "stream": false added so the whole reply arrives as a single JSON object instead of a stream of one-line objects.
curl http://localhost:11434/api/generate -d '{
"model": "llama3.2",
"prompt": "Why is the sky blue?",
"stream": false
}'
| Check on the reply | What you should see |
|---|---|
| It is one JSON object | A single object, not one JSON object per line |
The response field has text |
The model’s answer, as one string |
done is true |
The generation finished, and the object also carries prompt_eval_count and eval_count |
Expected result. We checked Ollama’s API reference and Serverman’s REST API guide. We did not send this request or run a model on this machine.
Limits
Each generate call stands alone: the endpoint keeps no memory between calls, so a follow-up question starts from nothing unless you paste the earlier text into the next prompt. The API reference also notes that the context field it returns is deprecated, so do not build a conversation on it. Without "stream": false, the reply arrives as a stream of JSON objects, one per piece of text, which a script must join together. And a one-shot reply can still be wrong, so check the facts in the answer, not just that it arrived. We did not test any of this ourselves.
