Once you've got Ollama running on your PC, sooner or later you'll want to call a model from a script or another app rather than typing into a chat window. Ollama's own API, which listens on http://localhost:11434 by default, gives you two main endpoints for text: /api/generate and /api/chat. They overlap a lot, but they're built for different jobs. This comparison is based on Ollama's API reference. It hasn't been timed or tested by us on specific hardware, and field names can change between Ollama releases, so check the docs for your version.
The short version
| /api/generate | /api/chat |
|---|
Input | A single prompt string (plus an optional system prompt) | A messages array, each message with a role and content |
Best for | One-off tasks: summarise this, classify that, complete this code | Conversations and assistants where earlier turns matter |
Roles | Not applicable | system, user, assistant and tool
|
Tool (function) calling | Not in the request schema | Yes, via a tools list; replies can contain tool_calls |
Fill-in-the-middle | Yes, via suffix | No |
Raw mode (no prompt template) | Yes, via raw | No |
Images | images array of Base64 strings
| images on individual messages
|
Reply field | response
| message (with role and content)
|
Both endpoints share many options: format for JSON or a JSON schema, stream, think, keep_alive, an options object for settings such as temperature, seed, num_ctx and num_predict, and log probabilities via logprobs.
/api/generate: one prompt in, one answer out
/api/generate is the simplest way to get text from a model. Ollama's reference shows a request as little as:
curl http://localhost:11434/api/generate -d '{
"model": "gemma4",
"prompt": "Why is the sky blue?",
"stream": false
}'
The answer comes back in the response field. Because each call is self-contained, it suits batch jobs where every prompt stands alone, such as tagging a folder of documents or rewriting product descriptions.
It also has two options /api/chat lacks. suffix is for fill-in-the-middle models: Ollama describes it as text that appears after the user prompt and before the model response, which is how code editors ask a model to complete the gap between two pieces of code. And raw returns the model's response without any prompt templating, for when you want to format the prompt yourself.
/api/chat takes a messages array. Each message has a role (system, user, assistant or tool) and content. To hold a conversation, your app sends the earlier messages back with each new request, so the model sees the whole history. The reply arrives as a message object with the role assistant.
This is the endpoint to use for chatbots, assistants and anything agent-like. Ollama's chat reference includes a tools field, described as an optional list of function tools the model may call, and responses can include tool_calls that your code then runs, returning the result as a tool message. Images for vision models go on individual messages; see our guide to vision models in Ollama.
Settings that work the same on both
Streaming: both stream partial responses by default; set "stream": false to get a single reply.
Structured output: format accepts json or a JSON schema. Our structured outputs guide covers this.
Thinking: think controls reasoning output on models that support it; see turning off thinking in Ollama.
Keeping models in memory: keep_alive takes a duration such as 5m, or 0 to unload straight away. See keeping Ollama models loaded.
Speed stats: both return timing fields including eval_count and eval_duration (in nanoseconds), so you can work out generation speed yourself.
What about the OpenAI-compatible API?
If you're plugging Ollama into a tool that already expects OpenAI's API format, you may not need either native endpoint. Our guide to using Ollama's OpenAI-compatible API explains that route, and the Ollama Python library guide covers calling these endpoints from Python without writing raw HTTP requests.
Our verdict
Use /api/chat for anything conversational, anything with a system/user/assistant structure, and anything that needs tool calling. Use /api/generate for single, standalone prompts, and when you need its extras: suffix for fill-in-the-middle code completion or raw to skip the prompt template.