<!-- llms-explorer concept facts · https://llms-explorer.com/tree/ollama-modelfile-authoring-from-and-parameter-and-template-and-system-and-adapter-and-message-and-license/ · pack 2026-10-14 · ~9846 tokens -->

# Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE

> A Modelfile is the blueprint to create and share customized models using Ollama. (from docs.ollama.com)

Parent: [Ollama core platform](https://llms-explorer.com/tree/ollama-core-platform/) · 8 facets · 139 facts · page: https://llms-explorer.com/tree/ollama-modelfile-authoring-from-and-parameter-and-template-and-system-and-adapter-and-message-and-license/

## Definitions

- messages = [{'role': 'user', 'content': "What is the temperature in New York?"}] — [source](https://docs.ollama.com/capabilities/tool-calling#tool-calling-with-streaming)
- messages = [{'role': 'user', 'content': 'What are the current weather conditions and temperature in New York and London?'}] — [source](https://docs.ollama.com/capabilities/tool-calling#parallel-tool-calling)
- const messages = [{ role: 'user', content: 'What are the current weather conditions and temperature in New York and London?' }] — [source](https://docs.ollama.com/capabilities/tool-calling#parallel-tool-calling)
- A Modelfile is the blueprint to create and share customized models using Ollama. — [source](https://docs.ollama.com/modelfile.md)
- * the **`Modelfile` is not case sensitive**. In the examples, uppercase instructions are used to make it easier to distinguish it from arguments. * Instructions can be in any order. In the examples, the `FROM` instruction is first to keep it easily readable. — [source](https://docs.ollama.com/modelfile.md#notes)

## How it works

- When using the API, specify the `num_ctx` parameter: — [source](https://docs.ollama.com/faq#how-can-i-specify-the-context-window-size)
- | Parameter | Description | Value Type | Example Usage | | - | - | - | - | | num\_ctx | Sets the size of the context window used to generate the next token. (Default: 2048) | int | num\_ctx 4096 | | repeat\_last\_n | Sets how far back for the model to look back to prevent repetition. (Default: 64, 0 = disabled, -1 = num\_ctx) | int | repeat\_last\_n 64 | | repeat\_penalty | Sets how strongly to penalize repetitions. A higher value (e.g., 1.5) will penalize repetitions more strongly, while a lower value (e.g., 0.9) will be more lenient. (Default: 1.0, disabled) | float | repeat\_penalty 1.1 | | — [source](https://docs.ollama.com/modelfile.md#valid-parameters-and-values)
- | Variable | Description | | - | - | | `{{ .System }}` | The system message used to specify custom behavior. | | `{{ .Prompt }}` | The user prompt message. | | `{{ .Response }}` | The response from the model. When generating a response, text after this variable is omitted. | — [source](https://docs.ollama.com/modelfile.md#template-variables)
- stopSets the stop sequences to use. When this pattern is encountered the LLM will stop generating text and return. Multiple stop patterns may be set by specifying multiple separate stop parameters in a modelfile.stringstop “AI assistant:“ — [source](https://docs.ollama.com/modelfile)
- Alternatively, you can change the amount of time all models are loaded into memory by setting the `OLLAMA_KEEP_ALIVE` environment variable when starting the Ollama server. The `OLLAMA_KEEP_ALIVE` variable uses the same parameter types as the `keep_alive` parameter types mentioned above. Refer to the section explaining [how to configure the Ollama server](#how-do-i-configure-ollama-server) to correctly set the environment variable. — [source](https://docs.ollama.com/faq#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately)

## How-to and procedures

- To view the Modelfile of a given model, use the `ollama show --modelfile` command. — [source](https://docs.ollama.com/modelfile.md#basic-modelfile)

## Examples and snippets

- ```json — `"model": "llama3.2",` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#response)
- ```shell theme={"system"} — `curl http://localhost:11434/api/generate -d '{` … — [source](https://docs.ollama.com/faq#how-can-i-specify-the-context-window-size)
- ``` — `FROM llama3.2` … — [source](https://docs.ollama.com/modelfile.md#basic-modelfile)
- ```shell — `curl http://localhost:11434/api/chat -d '{` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#request)
- ```shell theme={"system"} — `curl https://ollama.com/api/chat \` … — [source](https://docs.ollama.com/api/authentication#api-keys)
- ```shell theme={"system"} — `curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": -1}'` … — [source](https://docs.ollama.com/faq#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately)
- ```shell theme={"system"} — `curl http://localhost:11434/api/generate -d '{"model": "llama3.2", "keep_alive": 0}'` … — [source](https://docs.ollama.com/faq#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately)
- ```json theme={"system"} — `"model": "gemma4",` … — [source](https://docs.ollama.com/api/usage.md#example-response)
- ```json — `"model": "llama3.1",` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#response)
- ```shell — `curl -X POST http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#request)
- ```powershell theme={"system"} — `(Invoke-WebRequest -method POST -Body '{"model":"llama3.2", "prompt":"Why is the sky blue?", "stream": false}'` … — [source](https://docs.ollama.com/windows#api-access)
- ```shell theme={"system"} — `/set parameter num_ctx 4096` … — [source](https://docs.ollama.com/faq#how-can-i-specify-the-context-window-size)
- ```shell theme={"system"} — `curl http://localhost:11434/api/generate -d '{"model": "mistral"}'` … — [source](https://docs.ollama.com/faq#how-can-i-preload-a-model-into-ollama-to-get-faster-response-times)
- ```json — `"model": "llava",` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#response)
- ```shell — `curl http://localhost:11434/api/create -d '{` … — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#request)
- ``` — `{{ if .System }}<|system|>` … — [source](https://huggingface.co/docs/hub/ollama#custom-chat-template-and-parameters)
- ```shell theme={"system"} — `docker build -t ollama-with-ca .` … — [source](https://docs.ollama.com/faq#how-do-i-use-ollama-behind-a-proxy-in-docker)
- ```nginx theme={"system"} — `server {` … — [source](https://docs.ollama.com/faq#how-can-i-use-ollama-with-a-proxy-server)
- ```shell theme={"system"} — `ngrok http 11434 --host-header="localhost:11434"` … — [source](https://docs.ollama.com/faq#how-can-i-use-ollama-with-ngrok)
- ```shell theme={"system"} — `cloudflared tunnel --url http://localhost:11434 --http-host-header="localhost:11434"` … — [source](https://docs.ollama.com/faq#how-can-i-use-ollama-with-cloudflare-tunnel)
- ```json theme={"system"} — `{"model":"gemma4","created_at":"2025-10-26T17:15:24.097767Z","response":"That","done":false}` … — [source](https://docs.ollama.com/api/streaming.md)
- ```shell theme={"system"} — `export ANTHROPIC_AUTH_TOKEN=ollama # required but ignored` … — [source](https://docs.ollama.com/api/anthropic-compatibility#environment-variables)
- ``` — `FROM <some model>` … — [source](https://docs.ollama.com/api/openai-compatibility#setting-the-local-context-size)
- ```shell choice.sh theme={"system"} — `curl http://localhost:11434/v1/systemone \` … — [source](https://docs.ollama.com/capabilities/decision#choose-a-label)
- ```shell image.sh theme={"system"} — `curl http://localhost:11434/v1/systemone \` … — [source](https://docs.ollama.com/capabilities/decision#judge-an-image)
- ```shell multiple.sh theme={"system"} — `curl http://localhost:11434/v1/systemone \` … — [source](https://docs.ollama.com/capabilities/decision#ask-multiple-questions)
- ```shell theme={"system"} — `docker run -d --gpus=all -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/ollama` … — [source](https://docs.ollama.com/docker#start-the-container)
- ```shell theme={"system"} — `docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/` … — [source](https://docs.ollama.com/docker#amd-gpu)
- ```shell theme={"system"} — `docker run -d --device /dev/kfd --device /dev/dri -v ollama:/root/.ollama -p 11434:11434 --name ollama ollama/` … — [source](https://docs.ollama.com/docker#vulkan-support)
- ```shell theme={"system"} — `ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_BASE_URL=http://localhost:11434 ANTHROPIC_API_KEY="" claude --model kimi` … — [source](https://docs.ollama.com/integrations/claude-code#manual-setup)
- ```shell theme={"system"} — `export COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1` … — [source](https://docs.ollama.com/integrations/copilot-cli#manual-setup)
- ```shell theme={"system"} — `COPILOT_PROVIDER_BASE_URL=http://localhost:11434/v1 COPILOT_PROVIDER_API_KEY= COPILOT_PROVIDER_WIRE_API=respon` … — [source](https://docs.ollama.com/integrations/copilot-cli#manual-setup)
- ```json theme={"system"} — `"custom_models": [` … — [source](https://docs.ollama.com/integrations/droid#manual-setup)
- ```json theme={"system"} — `"custom_models": [` … — [source](https://docs.ollama.com/integrations/droid#cloud-models)
- ```shell theme={"system"} — `export POOLSIDE_STANDALONE_BASE_URL=http://localhost:11434/v1` … — [source](https://docs.ollama.com/integrations/pool#manual-setup)
- ```shell theme={"system"} — `POOLSIDE_STANDALONE_BASE_URL=http://localhost:11434/v1 POOLSIDE_API_KEY=ollama pool -m kimi-k2.6:cloud` … — [source](https://docs.ollama.com/integrations/pool#manual-setup)

## Measurements and reference values

- Un Modelfile de Ollama es una configuración que permite personalizar y gestionar las modelos que utiliza para la creación de contenido. total duration: 606.975347ms prompt eval count: 41 token(s) prompt eval cached: 40 token(s) eval count: 30 token(s) eval rate: 52.48 tokens/s — [source](https://jacar.es/en/import-hugging-face-model-into-ollama/)

## Problems, failure modes and limitations

- Per the api.md reference, done_reason "load" is returned for a chat call with empty messages (loads the model) and "unload" for an empty prompt/messages with keep_alive:0. keep_alive defaults to 5m. Raw mode (raw:true) skips templating and returns no `context`; `context` is deprecated. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md)
- Errors raised before streaming begins return an HTTP status (400 bad request/invalid JSON, 404 model not found, 429 rate limit, 500 internal, 502 bad gateway when a cloud model is unreachable) with a JSON body {"error": "<message>"}. — [source](https://docs.ollama.com/api/errors.md)
- - `truncate`: truncates the end of each input to fit within context length. Returns error if `false` and context length is exceeded. Defaults to `true` - `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature` - `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`) - `dimensions`: number of dimensions for the embedding — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#parameters)
- 1 - Error occurred (invalid Modelfile, missing base model, etc.) — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- Error: specified Modelfile wasn't found — [source](https://mintlify.wiki/ollama/ollama/cli/create)

## Comparisons and alternatives

- - `format`: the format to return a response in. Format can be `json` or a JSON schema - `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature` - `system`: system message to (overrides what is defined in the `Modelfile`) - `template`: the prompt template to use (overrides what is defined in the `Modelfile`) - `stream`: if `false` the response will be returned as a single response object, rather than a stream of objects - `raw`: if `true` no formatting will be applied to the prompt. You may choose — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#parameters)
- - `format`: the format to return a response in. Format can be `json` or a JSON schema. - `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature` - `stream`: if `false` the response will be returned as a single response object, rather than a stream of objects - `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`) — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#parameters)
- It's the maximum number of tokens the model can hold in one request: your system prompt, tool schemas, conversation history and current message combined. Current Ollama builds pick the default from VRAM (4096 under roughly 24 GiB, 32K to 48 GiB, 256K above), while the FAQ still says 4096 and the Modelfile reference still says 2048. Check yours with ollama ps rather than trusting any published figure. — [source](https://www.betterclaw.io/blog/ollama-context-window-truncates-agent-config)
- If you want to set custom options for the model at runtime rather than in the Modelfile, you can do so with the `options` parameter. This example sets every available option, but you can set any of them individually and omit the ones you do not want to override. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#generate-request-with-options)

## Facts and statements

- ```shell theme={"system"} curl -s http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{ "model": "qwen3", "messages": [{"role": "user", "content": "What are the current weather conditions and temperature in New York and London?"}], "stream": false, "tools": [ { "type": "function", "function": { "name": "get_temperature", "description": "Get the current temperature for a city", "parameters": { "type": "object", "required": ["city"], "properties": { "city": {"type": "string", "description": "The name of the city"} } } } }, { "type": "function", "function": { "name": "get_cond — [source](https://docs.ollama.com/capabilities/tool-calling#parallel-tool-calling)
- <Tabs> <Tab title="Ollama API"> ```shell theme={"system"} curl http://localhost:11434/api/chat \ -H "Content-Type: application/json" \ -d '{ "model": "gemma4:e2b", "messages": [ { "role": "user", "content": "Say hello in one sentence." } ], "stream": false }' ``` </Tab> — [source](https://docs.ollama.com/quickstart#2-send-a-request)
- Generate chunks put text in the `response` field; chat chunks put it in `message.content`. The last chunk sets done:true and carries done_reason (e.g. "stop"). — [source](https://docs.ollama.com/api/streaming.md)
- Read the answer from `message.content`. For local inference, use `http://localhost:11434/api/chat` with a downloaded model and omit the authorization header. — [source](https://docs.ollama.com/api/introduction#ollama-api-example)
- ```shell theme={"system"} curl -s http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{ "model": "qwen3", "messages": [ {"role": "user", "content": "What is the temperature in New York?"}, { "role": "assistant", "tool_calls": [ { "type": "function", "function": { "index": 0, "name": "get_temperature", "arguments": {"city": "New York"} } } ] }, {"role": "tool", "tool_name": "get_temperature", "content": "22°C"} ], "stream": false }' ``` </Tab> — [source](https://docs.ollama.com/capabilities/tool-calling#calling-a-single-tool)
- ```shell theme={"system"} curl -s http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{ "model": "qwen3", "messages": [ {"role": "user", "content": "What are the current weather conditions and temperature in New York and London?"}, { "role": "assistant", "tool_calls": [ { "type": "function", "function": { "index": 0, "name": "get_temperature", "arguments": {"city": "New York"} } }, { "type": "function", "function": { "index": 1, "name": "get_conditions", "arguments": {"city": "New York"} } }, { "type": "function", "function": { "index": 2, "name": "get_temperature", "argume — [source](https://docs.ollama.com/capabilities/tool-calling#parallel-tool-calling)
- <Tabs> <Tab title="cURL"> ```shell theme={"system"} curl -s http://localhost:11434/api/chat -H "Content-Type: application/json" -d '{ "model": "qwen3", "messages": [{"role": "user", "content": "What is the temperature in New York?"}], "stream": false, "tools": [ { "type": "function", "function": { "name": "get_temperature", "description": "Get the current temperature for a city", "parameters": { "type": "object", "required": ["city"], "properties": { "city": {"type": "string", "description": "The name of the city"} } } } } ] }' ``` — [source](https://docs.ollama.com/capabilities/tool-calling#calling-a-single-tool)
- If you're using the API, use the `keep_alive` parameter with the `/api/generate` and `/api/chat` endpoints to set the amount of time that a model stays in memory. The `keep_alive` parameter can be set to: — [source](https://docs.ollama.com/faq#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately)
- The `keep_alive` API parameter with the `/api/generate` and `/api/chat` API endpoints will override the `OLLAMA_KEEP_ALIVE` setting. — [source](https://docs.ollama.com/faq#how-do-i-keep-a-model-loaded-in-memory-or-make-it-unload-immediately)
- <Tabs> <Tab title="Ollama API"> ```shell theme={"system"} curl https://ollama.com/api/chat \ -H "Authorization: Bearer $OLLAMA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemma4:31b", "messages": [ { "role": "user", "content": "Say hello in one sentence." } ], "stream": false }' ``` — [source](https://docs.ollama.com/quickstart#2-send-a-request)
- If your framework points at http://localhost:11434/v1, passing num_ctx in the request body does nothing. Set OLLAMA_CONTEXT_LENGTH on the server, or bake num_ctx into a Modelfile, so the value applies before the request arrives. — [source](https://www.betterclaw.io/blog/ollama-context-window-truncates-agent-config)
- Show information about a model including details, modelfile, template, parameters, license, system prompt. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#show-model-information)
- Ollama's own documentation currently disagrees with itself. The FAQ says the default is 4096. The Modelfile reference says num_ctx defaults to 2048. The context length page describes a default derived from available VRAM: 4K below 24 GiB, 32K from 24 to 48 GiB, and 256K above that. Each of those was true of some build, and the VRAM-derived version is what current releases actually do. — [source](https://www.betterclaw.io/blog/ollama-context-window-truncates-agent-config)
- # 3. Send it to Ollama curl -X POST http://localhost:11434/api/chat \ -H "Content-Type: application/json" \ -d '{ "model": "gemma4", "messages": [{ "role": "user", "content": "What is in this image?", "images": ["'"$IMG"'"] }], "stream": false }' ``` </Tab> — [source](https://docs.ollama.com/capabilities/vision#usage-with-ollama-s-api)
- - `options`: additional model parameters listed in the documentation for the [Modelfile](./modelfile.mdx#valid-parameters-and-values) such as `temperature` - `keep_alive`: controls how long the model will stay loaded into memory following the request (default: `5m`) — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#parameters)
- | Instruction | Description | | - | - | | [`FROM`](#from-required) (required) | Defines the base model to use. | | [`PARAMETER`](#parameter) | Sets the parameters for how Ollama will run the model. | | [`TEMPLATE`](#template) | The full prompt template to be sent to the model. | | [`SYSTEM`](#system) | Specifies the system message that will be set in the template. | | [`LICENSE`](#license) | Specifies the legal license. | | [`MESSAGE`](#message) | Specify message history. | | [`REQUIRES`](#requires) | Specify the minimum version of Ollama required by the model. | | [`CAPABILITY`](#capability) — [source](https://docs.ollama.com/modelfile.md#format)
- async function agentLoop() { const messages = [{ role: 'user', content: 'What is (11434+12341)*412?' }] — [source](https://docs.ollama.com/capabilities/tool-calling#multi-turn-tool-calling-agent-loop)
- Why you do not need TEMPLATE in the Modelfile — [source](https://jacar.es/en/import-hugging-face-model-into-ollama/)
- So skip the lookup tables. The default is a property of your Ollama version and machine, not of the model you pulled, unless that model's own Modelfile sets num_ctx. Run ollama show yourmodel, then ollama ps. Two commands beat any list. — [source](https://www.betterclaw.io/blog/ollama-context-window-truncates-agent-config)
- ```shell streaming.sh theme={"system"} curl -X POST http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3-coder", "max_tokens": 1024, "stream": true, "messages": [{ "role": "user", "content": "Count from 1 to 10" }] }' ``` </CodeGroup> — [source](https://docs.ollama.com/api/anthropic-compatibility#streaming-example)
- You can optionally configure a system prompt by putting it into a new file named `system` in the repository. — [source](https://huggingface.co/docs/hub/ollama#custom-chat-template-and-parameters)
- Read text blocks from content. The cloud endpoint requires Authorization: Bearer; it does not accept x-api-key alone. Compatible models support messages, streaming, and function calling. Tool-choice controls, deferred tools, and hosted web search are not fully supported. — [source](https://docs.ollama.com/api/anthropic-compatibility)
- for call in tool_calls: if call.function.name == 'get_temperature': result = get_temperature(**call.function.arguments) else: result = 'Unknown tool' messages.append({'role': 'tool', 'tool_name': call.function.name, 'content': result}) ``` </Tab> — [source](https://docs.ollama.com/capabilities/tool-calling#tool-calling-with-streaming)
- const getTemperatureTool = { type: 'function', function: { name: 'get_temperature', description: 'Get the current temperature for a city', parameters: { type: 'object', required: ['city'], properties: { city: { type: 'string', description: 'The name of the city' }, }, }, }, } — [source](https://docs.ollama.com/capabilities/tool-calling#tool-calling-with-streaming)
- async function agentLoop() { const messages = [{ role: 'user', content: "What is the temperature in New York?" }] — [source](https://docs.ollama.com/capabilities/tool-calling#tool-calling-with-streaming)
- for (const call of toolCalls) { if (call.function.name === 'get_temperature') { const args = call.function.arguments as { city: string } const result = getTemperature(args.city) messages.push({ role: 'tool', tool_name: call.function.name, content: result } ) } else { messages.push({ role: 'tool', tool_name: call.function.name, content: 'Unknown tool' } ) } } } } — [source](https://docs.ollama.com/capabilities/tool-calling#tool-calling-with-streaming)
- TEMPLATE """{{ if .System }}<|start_header_id|>system<|end_header_id|> {{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|> {{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|> {{ .Response }}<|eot_id|>""" PARAMETER stop "<|start_header_id|>" PARAMETER stop "<|end_header_id|>" PARAMETER stop "<|eot_id|>" PARAMETER stop "<|reserved_special_token" — [source](https://crystal-method.com/blog/ollama-modelfile/)
- `TEMPLATE` of the full prompt template to be passed into the model. It may include (optionally) a system message, a user's message and the response from the model. Note: syntax may be model specific. Templates use Go [template syntax](https://pkg.go.dev/text/template). — [source](https://docs.ollama.com/modelfile.md#template)
- The `SYSTEM` instruction specifies the system message to be used in the template, if applicable. — [source](https://docs.ollama.com/modelfile.md#system)
- The num_ctx parameter raises the context above the 4096 tokens Ollama assigns by default on a machine without a GPU, according to its own log. The num_thread parameter caps the CPU threads, and the performance section explains why I added it. The SYSTEM line sets the answer language to peninsular Spanish. Then create and check the model: — [source](https://jacar.es/en/import-hugging-face-model-into-ollama/)
- If the messages array is empty and the `keep_alive` parameter is set to `0`, a model will be unloaded from memory. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#unload-a-model)
- SYSTEMSpecifies the system message that will be set in the template. — [source](https://docs.ollama.com/modelfile)
- curl -X POST http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3-coder", "max_tokens": 1024, "stream": true, "messages": [{ "role": "user", "content": "Count from 1 to 10" }] }' — [source](https://docs.ollama.com/api/anthropic-compatibility)
- <Tab title="Anthropic Messages"> ```shell theme={"system"} curl http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "gemma4:e2b", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Say hello in one sentence." } ] }' ``` — [source](https://docs.ollama.com/quickstart#2-send-a-request)
- - `parameters`: (optional) a dictionary of parameters for the model (see [Modelfile](./modelfile.mdx#valid-parameters-and-values) for a list of parameters) — [source](https://github.com/ollama/ollama/pull/14969)
- Tool calling is supported by providing a list of tools in the `tools` parameter. The model will generate a response that includes a list of tool calls. See the [Chat request (Streaming with tools)](#chat-request-streaming-with-tools) example below. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#tool-calling)
- Compatible models support messages, streaming, and function calling. Tool-choice controls, deferred tools, and hosted web search are not fully supported. — [source](https://docs.ollama.com/api/anthropic-compatibility#direct-cloud-access)
- <CodeGroup> ```python tools.py theme={"system"} import anthropic — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- message = client.messages.create( model='qwen3-coder', max_tokens=1024, tools=[ { 'name': 'get_weather', 'description': 'Get the current weather in a location', 'input_schema': { 'type': 'object', 'properties': { 'location': { 'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA' } }, 'required': ['location'] } } ], messages=[{'role': 'user', 'content': "What's the weather in San Francisco?"}] ) — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- for block in message.content: if block.type == 'tool_use': print(f'Tool: {block.name}') print(f'Input: {block.input}') ``` — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- ```javascript tools.js theme={"system"} import Anthropic from "@anthropic-ai/sdk"; — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- const message = await anthropic.messages.create({ model: "qwen3-coder", max_tokens: 1024, tools: [ { name: "get_weather", description: "Get the current weather in a location", input_schema: { type: "object", properties: { location: { type: "string", description: "The city and state, e.g. San Francisco, CA", }, }, required: ["location"], }, }, ], messages: [{ role: "user", content: "What's the weather in San Francisco?" }], }); — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- for (const block of message.content) { if (block.type === "tool_use") { console.log("Tool:", block.name); console.log("Input:", block.input); } } ``` — [source](https://docs.ollama.com/api/anthropic-compatibility#tool-calling-example)
- const tools = [ { type: 'function', function: { name: 'get_temperature', description: 'Get the current temperature for a city', parameters: { type: 'object', required: ['city'], properties: { city: { type: 'string', description: 'The name of the city' }, }, }, }, }, { type: 'function', function: { name: 'get_conditions', description: 'Get the current weather conditions for a city', parameters: { type: 'object', required: ['city'], properties: { city: { type: 'string', description: 'The name of the city' }, }, }, }, } ] — [source](https://docs.ollama.com/capabilities/tool-calling#parallel-tool-calling)
- const tools = [ { type: 'function', function: { name: 'add', description: 'Add two numbers', parameters: { type: 'object', required: ['a', 'b'], properties: { a: { type: 'integer', description: 'The first number' }, b: { type: 'integer', description: 'The second number' }, }, }, }, }, { type: 'function', function: { name: 'multiply', description: 'Multiply two numbers', parameters: { type: 'object', required: ['a', 'b'], properties: { a: { type: 'integer', description: 'The first number' }, b: { type: 'integer', description: 'The second number' }, }, }, }, }, ] — [source](https://docs.ollama.com/capabilities/tool-calling#multi-turn-tool-calling-agent-loop)
- const args = call.function.arguments as { a: number; b: number } console.log(`Calling ${call.function.name} with arguments`, args) const result = fn(args.a, args.b) console.log(`Result: ${result}`) messages.push({ role: 'tool', tool_name: call.function.name, content: String(result) }) } } else { break } } } — [source](https://docs.ollama.com/capabilities/tool-calling#multi-turn-tool-calling-agent-loop)
- ```bash theme={"system"} launchctl setenv OLLAMA_HOST "0.0.0.0:11434" ``` — [source](https://docs.ollama.com/faq#setting-environment-variables-on-mac)
- ```ini theme={"system"} [Service] Environment="OLLAMA_HOST=0.0.0.0:11434" ``` — [source](https://docs.ollama.com/faq#setting-environment-variables-on-linux)
- PARAMETER num_ctx 4096 PARAMETER temperature 0.7 PARAMETER top_k 40 PARAMETER top_p 0.9 PARAMETER repeat_penalty 1.1 PARAMETER seed 42 — [source](https://crystal-method.com/blog/ollama-modelfile/)
- TEMPLATE """{{ if .System }}<|im_start|>system {{ .System }}<|im_end|> {{ end }}{{ if .Prompt }}<|im_start|>user {{ .Prompt }}<|im_end|> {{ end }}<|im_start|>assistant """ — [source](https://crystal-method.com/blog/ollama-modelfile/)
- PARAMETER num_ctx 8192 PARAMETER temperature 0.7 — [source](https://crystal-method.com/blog/ollama-modelfile/)
- <|channel|>analysis<|message|>{long chain of thought}<|end|><|start|>assistant<|channel|>commentary<|message|>**Action plan**: 1. Generate an HTML file 2. Generate a JavaScript for the Node.js server 3. Start the server --- Will start executing the plan step by step<|end|><|start|>assistant<|channel|>commentary to=functions.generate_file<|constrain|>json<|message|>{"template": "basic_html", "path": "index.html"}<|call|> — [source](https://developers.openai.com/cookbook/articles/openai-harmony#functions)
- If an empty prompt is provided and the `keep_alive` parameter is set to `0`, a model will be unloaded from memory. — [source](https://raw.githubusercontent.com/ollama/ollama/main/docs/api.md#unload-a-model)
- Copy FROM yourmodel PARAMETER num_ctx 16384 — [source](https://www.betterclaw.io/blog/ollama-context-window-truncates-agent-config)
- FROM <some model> PARAMETER num_ctx <context size> — [source](https://docs.ollama.com/api/openai-compatibility)
- curl -X POST http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: ollama" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "qwen3-coder", "max_tokens": 1024, "messages": [{ "role": "user", "content": "Hello, how are you?" }] }' — [source](https://docs.ollama.com/api/anthropic-compatibility)
- curl -X POST http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3-coder", "max_tokens": 1024, "tools": [ { "name": "get_weather", "description": "Get the current weather in a location", "input_schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state" } }, "required": ["location"] } } ], "messages": [{ "role": "user", "content": "What is the weather in San Francisco?" }] }' — [source](https://docs.ollama.com/api/anthropic-compatibility)
- curl http://localhost:11434/v1/messages \ -H "Content-Type: application/json" \ -d '{ "model": "claude-3-5-sonnet", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Hello!" } ] }' — [source](https://docs.ollama.com/api/anthropic-compatibility)
- TEMPLATE """{{ .System }} — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- PARAMETER temperature 0.8 PARAMETER num_ctx 4096 — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- TEMPLATE """### System: {{ .System }} — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- PARAMETER temperature 0.7 PARAMETER num_ctx 8192 PARAMETER stop "User:" PARAMETER stop "Assistant:" — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- TEMPLATE """[INST] {{ .System }} — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- /openapi.yaml post /api/chat Generate the next chat message in a conversation between a user and an assistant. — [source](https://docs.ollama.com/api/chat)
- <Tab title="cURL"> ```shell theme={"system"} curl -X POST http://localhost:11434/api/embed \ -H "Content-Type: application/json" \ -d '{ "model": "embeddinggemma", "input": "The quick brown fox jumps over the lazy dog." }' ``` </Tab> — [source](https://docs.ollama.com/capabilities/embeddings#generate-embeddings)
- <Tabs> <Tab title="cURL"> ```shell theme={"system"} curl -X POST http://localhost:11434/api/embed \ -H "Content-Type: application/json" \ -d '{ "model": "embeddinggemma", "input": [ "First sentence", "Second sentence", "Third sentence" ] }' ``` </Tab> — [source](https://docs.ollama.com/capabilities/embeddings#generate-a-batch-of-embeddings)
- <Tab title="OpenAI Responses"> ```shell theme={"system"} curl http://localhost:11434/v1/responses \ -H "Content-Type: application/json" \ -d '{ "model": "gemma4:e2b", "input": "Say hello in one sentence." }' ``` — [source](https://docs.ollama.com/quickstart#2-send-a-request)
- 本記事はOllama公式ドキュメント（Modelfile Reference）の仕様を一次ソースとして、全インストラクションの構文・全パラメータの既定値・ビルド手順を整理する（2026-07-19確認）。Ollama自体の導入やモデル選定についてはOllama導入ガイドとOllamaモデル選定ガイドを参照してほしい。 — [source](https://crystal-method.com/blog/ollama-modelfile/)
- 先頭のコメント行：# Modelfile generated by "ollama show" に続き、# To build a new Modelfile based on this one, replace the FROM line with: # FROM llama3.2:latest と書かれている。出力されたFROMはblobの実体パスを指しているため、派生モデルを作るときはこの行をモデル名に書き換えるのが公式の指示だ — [source](https://crystal-method.com/blog/ollama-modelfile/)
- ビルドはollama create <名前> -f ./Modelfile、実行はollama run <名前> — [source](https://crystal-method.com/blog/ollama-modelfile/)
- The format of the `Modelfile`: — [source](https://docs.ollama.com/modelfile.md#format)
- An example of a `Modelfile` creating a mario blueprint: — [source](https://docs.ollama.com/modelfile.md#basic-modelfile)
- The `LICENSE` instruction allows you to specify the legal license under which the model used with this Modelfile is shared or distributed. — [source](https://docs.ollama.com/modelfile.md#license)
- How to create the model in Ollama with a Modelfile — [source](https://jacar.es/en/import-hugging-face-model-into-ollama/)
- Save it as a file (e.g. Modelfile) — [source](https://docs.ollama.com/modelfile)
- Short: -fPath to the Modelfile. Defaults to Modelfile in the current directory. — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- Keep your Modelfile in version control and document what each version changes. — [source](https://mintlify.wiki/ollama/ollama/cli/create)
- Ollama Mastery is 15 chapters end to end — install, model choice, Modelfiles, GPU offload, the API, and the 20 errors that actually happen. Plus 24 more courses. — [source](https://localaimaster.com/blog/ollama-digest-mismatch)
- The OpenAI API does not have a way of setting the context size for a model. If you need to change the context size, create a `Modelfile` which looks like: — [source](https://docs.ollama.com/api/openai-compatibility#setting-the-local-context-size)
- できます。ollama show --modelfile llama3.2のように実行すると、そのモデルのFROM・TEMPLATE・PARAMETERの定義が出力されます。TEMPLATEやstopはモデル固有のため、自作する前に元の定義を確認するのが確実です。 — [source](https://crystal-method.com/blog/ollama-modelfile/)
- TEMPLATEThe full prompt template to be sent to the model. — [source](https://docs.ollama.com/modelfile)
- Chat template that formats prompts. Uses Go template syntax. — [source](https://mintlify.wiki/ollama/ollama/cli/create)

## Related concepts

- MESSAGE — is a related of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- SYSTEM — is a related of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- localhost:11434 — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- PARAMETER — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- stream — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- tool_calls — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- /api/chat — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- TEMPLATE — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- num_ctx — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- keep_alive — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- done_reason — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- eval_count — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- prompt_eval_duration — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- /api/generate — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- context window — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- NDJSON — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- REQUIRES — is a related of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
- /api/create — is a part of Ollama Modelfile authoring: FROM and PARAMETER and TEMPLATE and SYSTEM and ADAPTER and MESSAGE and LICENSE
