[GH-ISSUE #8793] Add support for Modelfile via the create API endpoint #5710

Open
opened 2026-04-12 17:00:20 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @DevOpsJeremy on GitHub (Feb 3, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8793

Originally assigned to: @pdevine on GitHub.

Currently, ollama create CLI command has a --file flag for providing a Modelfile. The API endpoint, on the other hand, requires the same options to be passed in JSON format in the request body, for example:

curl http://localhost:11434/api/create -d '{
  "model": "mario",
  "from": "llama3.2",
  "system": "You are Mario from Super Mario Bros."
}'

If one wanted to use a Modelfile to define the FROM, SYSTEM, etc. they should be able to in a method like this:

/path/to/Modelfile

FROM llama3.2
SYSTEM You are Mario from Super Mario Bros.
curl http://localhost:11434/api/create -d '{
  "model": "mario",
  "modelfile": "/path/to/Modelfile"
}'

I'm proposing adding support to provide a Modelfile to the create API endpoint instead of the need to convert the Modelfile specifications into a JSON format and pass to the body of the request.

Originally created by @DevOpsJeremy on GitHub (Feb 3, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8793 Originally assigned to: @pdevine on GitHub. Currently, `ollama create` CLI command has a `--file` flag for providing a [`Modelfile`](https://github.com/ollama/ollama/blob/main/docs/modelfile.md). The [API endpoint](https://github.com/ollama/ollama/blob/main/docs/api.md#create-a-model), on the other hand, requires the same options to be passed in JSON format in the request body, [for example](https://github.com/ollama/ollama/blob/main/docs/api.md#chat-request-reproducible-outputs): ```bash curl http://localhost:11434/api/create -d '{ "model": "mario", "from": "llama3.2", "system": "You are Mario from Super Mario Bros." }' ``` If one wanted to use a Modelfile to define the `FROM`, `SYSTEM`, etc. they should be able to in a method like this: `/path/to/Modelfile` ```dockerfile FROM llama3.2 SYSTEM You are Mario from Super Mario Bros. ``` ```bash curl http://localhost:11434/api/create -d '{ "model": "mario", "modelfile": "/path/to/Modelfile" }' ``` I'm proposing adding support to provide a Modelfile to the `create` API endpoint instead of the need to convert the Modelfile specifications into a JSON format and pass to the body of the request.
GiteaMirror added the feature request label 2026-04-12 17:00:20 -05:00
Author
Owner

@pdevine commented on GitHub (Feb 3, 2025):

Hey @DevOpsJeremy, was there a usecase that you were trying to do?

We did (until very recently) allow you to send the Modelfile as part of the create request but there are two issues:

  1. it forced devs to (unnecessarily) have to create a modelfile in order to do simple operations; and
  2. it resulted in sometimes weird serialization problems

As for allowing a "path" to the modelfile, there are security implications there (i.e. call an API and have it read an arbitrary file off of the disk) and it would only work if the ollama server was running locally on your machine.

<!-- gh-comment-id:2631868734 --> @pdevine commented on GitHub (Feb 3, 2025): Hey @DevOpsJeremy, was there a usecase that you were trying to do? We did (until very recently) allow you to send the Modelfile as part of the create request but there are two issues: 1. it forced devs to (unnecessarily) have to create a modelfile in order to do simple operations; and 2. it resulted in sometimes weird serialization problems As for allowing a "path" to the modelfile, there are security implications there (i.e. call an API and have it read an arbitrary file off of the disk) and it would only work if the ollama server was running locally on your machine.
Author
Owner

@DevOpsJeremy commented on GitHub (Feb 3, 2025):

Hi @pdevine

I'm trying to use ollama in a CI pipeline. The idea is that a Modelfile can be kept in the repo & the pipeline can create the model from the Modelfile then use that new model for pushing, sending prompts, etc.

The ollama create CLI has worked, although it's not ideal for non-interactive scripts. The API endpoint would be preferred, but that brings me back to the Modelfile issue.

For more customization & consistency, I'd like to include all model specifications in a Modelfile hosted in the repo instead of passing it as JSON within the CI pipeline.

Is it possible to support both? In that the create endpoint accepts either:

A. Options passed via the body of the request.

or

B. A Modelfile

<!-- gh-comment-id:2631892202 --> @DevOpsJeremy commented on GitHub (Feb 3, 2025): Hi @pdevine I'm trying to use `ollama` in a CI pipeline. The idea is that a Modelfile can be kept in the repo & the pipeline can create the model from the Modelfile then use that new model for pushing, sending prompts, etc. The `ollama create` CLI has worked, although it's not ideal for non-interactive scripts. The API endpoint would be preferred, but that brings me back to the Modelfile issue. For more customization & consistency, I'd like to include all model specifications in a Modelfile hosted in the repo instead of passing it as JSON within the CI pipeline. Is it possible to support both? In that the `create` endpoint accepts either: A. Options passed via the body of the request. _**or**_ B. A Modelfile
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5710