[GH-ISSUE #7528] Cannot get a model prefixed with a namespace from /v1/models/{model} endpoint #66844

Closed
opened 2026-05-04 08:22:54 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @skobkin on GitHub (Nov 6, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/7528

What is the issue?

My initial goal is to check if specific model is available using Ollama API.

I use OpenAI library github.com/sashabaranov/go-openai to do that.

The problem is when I try to get models which are not present in the main catalog and have an author prefix, I'm getting 404 and non-JSON response like if the routing is failing.

To eliminate the possibility of the library bug I tried to do the same with CURL.

The first thing I did is requests full list of models to be sure that the model is really in the list:

curl http://localhost:11434/v1/models

which resulted in the following response:

{"object":"list","data":[{"id":"T-lite-instruct-0.1.Q4_K_M.gguf:latest","object":"model","created":1730118522,"owned_by":"library"},{"id":"x/llama3.2-vision:11b-instruct-q8_0","object":"model","created":1729612391,"owned_by":"x"},{"id":"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"},{"id":"llama3.2:3b-instruct-q4_K_M","object":"model","created":1727650425,"owned_by":"library"},{"id":"reader-lm:1.5b-q6_K","object":"model","created":1727092629,"owned_by":"library"},{"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"},{"id":"phi3:14b-medium-4k-instruct-q4_K_M","object":"model","created":1727092620,"owned_by":"library"},{"id":"nuextract:3.8b-q4_K_M","object":"model","created":1727092619,"owned_by":"library"},{"id":"hermes3:8b-llama3.1-q6_K","object":"model","created":1727092618,"owned_by":"library"},{"id":"nomic-embed-text:latest","object":"model","created":1727092617,"owned_by":"library"},{"id":"nemotron-mini:4b-instruct-q4_K_M","object":"model","created":1727092615,"owned_by":"library"},{"id":"mxbai-embed-large:latest","object":"model","created":1727092614,"owned_by":"library"},{"id":"mistral-nemo:12b-instruct-2407-q4_K_M","object":"model","created":1727092613,"owned_by":"library"},{"id":"llama3.1:8b-instruct-q6_K","object":"model","created":1727092609,"owned_by":"library"},{"id":"gemma2:9b-instruct-q4_K_M","object":"model","created":1727092603,"owned_by":"library"},{"id":"gemma2:27b-instruct-q4_K_M","object":"model","created":1727092601,"owned_by":"library"},{"id":"deepseek-coder-v2:16b-lite-instruct-q4_K_M","object":"model","created":1727092600,"owned_by":"library"},{"id":"codellama:13b-instruct-q4_K_M","object":"model","created":1727092599,"owned_by":"library"},"id":"codegemma:latest","object":"model","created":1727092598,"owned_by":"library"},{"id":"phi3:3.8b-mini-instruct-4k-q4_K_M","object":"model","created":1713898146,"owned_by":"library"}]}

So here's the model I wanted to request: {"id" :"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"}

curl http://localhost:11434/v1/models/mannix/llama3.1-8b-lexi:q8_0

No luck:

404 page not found%

The problem is very obvious if you know how back-end works. It looks really like a routing problem.

The obvious solution for me was to encode the value to remove the / character from the URL:

curl http://localhost:11434/v1/models/mannix%2Fllama3.1-8b-lexi%3Aq8_0

I've got an error again:

404 page not found%

To ensure that I'm using correct endpoint, I've tried with another model:

curl http://localhost:11434/v1/models/qwen2:7b-instruct-q4_K_M

It worked:

{"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"}

When I request non-encoded model ID, Ollama logs show this:

ollama             | [GIN] 2024/11/06 - 15:59:11 | 404 |      13.715µs |      172.24.0.1 | GET      "/v1/models/mannix/llama3.1-8b-lexi:q8_0"

When I request encoded model ID, Ollama logs show this:

ollama             | [GIN] 2024/11/06 - 15:58:01 | 404 |      15.239µs |      172.24.0.1 | GET      "/v1/models/mannix/llama3.1-8b-lexi:q8_0"

Which is basically the same result, so I guess the reason of a failure may be in the fact that URL is being decoded before matching the route for some reason.

Most likely the same should be applicable for all previous Ollama versions and not only 0.4.0-rc6

OS

Docker

GPU

AMD

CPU

AMD

Ollama version

0.4.0-rc6

Originally created by @skobkin on GitHub (Nov 6, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/7528 ### What is the issue? My initial goal is to check if specific model is available using Ollama API. I use OpenAI library `github.com/sashabaranov/go-openai` to do that. The problem is when I try to get models which are not present in the main catalog and have an author prefix, I'm getting `404` and non-JSON response like if the routing is failing. To eliminate the possibility of the library bug I tried to do the same with CURL. The first thing I did is requests full list of models to be sure that the model is really in the list: ``` shell curl http://localhost:11434/v1/models ``` which resulted in the following response: ```json {"object":"list","data":[{"id":"T-lite-instruct-0.1.Q4_K_M.gguf:latest","object":"model","created":1730118522,"owned_by":"library"},{"id":"x/llama3.2-vision:11b-instruct-q8_0","object":"model","created":1729612391,"owned_by":"x"},{"id":"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"},{"id":"llama3.2:3b-instruct-q4_K_M","object":"model","created":1727650425,"owned_by":"library"},{"id":"reader-lm:1.5b-q6_K","object":"model","created":1727092629,"owned_by":"library"},{"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"},{"id":"phi3:14b-medium-4k-instruct-q4_K_M","object":"model","created":1727092620,"owned_by":"library"},{"id":"nuextract:3.8b-q4_K_M","object":"model","created":1727092619,"owned_by":"library"},{"id":"hermes3:8b-llama3.1-q6_K","object":"model","created":1727092618,"owned_by":"library"},{"id":"nomic-embed-text:latest","object":"model","created":1727092617,"owned_by":"library"},{"id":"nemotron-mini:4b-instruct-q4_K_M","object":"model","created":1727092615,"owned_by":"library"},{"id":"mxbai-embed-large:latest","object":"model","created":1727092614,"owned_by":"library"},{"id":"mistral-nemo:12b-instruct-2407-q4_K_M","object":"model","created":1727092613,"owned_by":"library"},{"id":"llama3.1:8b-instruct-q6_K","object":"model","created":1727092609,"owned_by":"library"},{"id":"gemma2:9b-instruct-q4_K_M","object":"model","created":1727092603,"owned_by":"library"},{"id":"gemma2:27b-instruct-q4_K_M","object":"model","created":1727092601,"owned_by":"library"},{"id":"deepseek-coder-v2:16b-lite-instruct-q4_K_M","object":"model","created":1727092600,"owned_by":"library"},{"id":"codellama:13b-instruct-q4_K_M","object":"model","created":1727092599,"owned_by":"library"},"id":"codegemma:latest","object":"model","created":1727092598,"owned_by":"library"},{"id":"phi3:3.8b-mini-instruct-4k-q4_K_M","object":"model","created":1713898146,"owned_by":"library"}]} ``` So here's the model I wanted to request: `{"id" :"mannix/llama3.1-8b-lexi:q8_0","object":"model","created":1729272492,"owned_by":"mannix"}` ```shell curl http://localhost:11434/v1/models/mannix/llama3.1-8b-lexi:q8_0 ``` No luck: ``` 404 page not found% ``` The problem is very obvious if you know how back-end works. It looks really like a routing problem. The obvious solution for me was to encode the value to remove the `/` character from the URL: ```shell curl http://localhost:11434/v1/models/mannix%2Fllama3.1-8b-lexi%3Aq8_0 ``` I've got an error again: ``` 404 page not found% ``` To ensure that I'm using correct endpoint, I've tried with another model: ```shell curl http://localhost:11434/v1/models/qwen2:7b-instruct-q4_K_M ``` It worked: ```json {"id":"qwen2:7b-instruct-q4_K_M","object":"model","created":1727092627,"owned_by":"library"} ``` When I request non-encoded model ID, Ollama logs show this: ``` ollama | [GIN] 2024/11/06 - 15:59:11 | 404 | 13.715µs | 172.24.0.1 | GET "/v1/models/mannix/llama3.1-8b-lexi:q8_0" ``` When I request encoded model ID, Ollama logs show this: ``` ollama | [GIN] 2024/11/06 - 15:58:01 | 404 | 15.239µs | 172.24.0.1 | GET "/v1/models/mannix/llama3.1-8b-lexi:q8_0" ``` Which is basically the same result, so I guess the reason of a failure may be in the fact that URL is being decoded before matching the route for some reason. Most likely the same should be applicable for all previous Ollama versions and not only `0.4.0-rc6` ### OS Docker ### GPU AMD ### CPU AMD ### Ollama version 0.4.0-rc6
GiteaMirror added the bugapi labels 2026-05-04 08:22:58 -05:00
Author
Owner

@skobkin commented on GitHub (Nov 6, 2024):

I've worked around my problem by requesting all models and searching locally, but this isn't the only case for requesting a model, so it should be possible to request such models too.

<!-- gh-comment-id:2460325122 --> @skobkin commented on GitHub (Nov 6, 2024): I've worked around my problem by requesting all models and searching locally, but this isn't the only case for requesting a model, so it should be possible to request such models too.
Author
Owner

@rick-github commented on GitHub (Nov 6, 2024):

Is using the OpenAI compatibility endpoint a requirement?

$ curl -s http://localhost:11434/api/show -d '{"model":"mannix/deepseek-coder-v2-lite-instruct:q5_k_m"}' | jq -S
{
  "details": {
    "families": [
      "deepseek2"
    ],
    "family": "deepseek2",
    "format": "gguf",
    "parameter_size": "15.7B",
    "parent_model": "",
...
<!-- gh-comment-id:2460481488 --> @rick-github commented on GitHub (Nov 6, 2024): Is using the OpenAI compatibility endpoint a requirement? ```console $ curl -s http://localhost:11434/api/show -d '{"model":"mannix/deepseek-coder-v2-lite-instruct:q5_k_m"}' | jq -S { "details": { "families": [ "deepseek2" ], "family": "deepseek2", "format": "gguf", "parameter_size": "15.7B", "parent_model": "", ... ```
Author
Owner

@skobkin commented on GitHub (Nov 7, 2024):

@rick-github It is preferable since the OpenAI related tools are usually well documented.

When starting that pet project I was looking for an Ollama specific SDK for Go, but didn't find anything good at the time. My first thought was to check Ollama itself since it's probably using its own API from CLI. But I didn't find anything documented, only the sources and I didn't have much time to research how it works.

If you can recommend a good library for Go to work with Ollama, please let me know. I'll check it out.

<!-- gh-comment-id:2461167828 --> @skobkin commented on GitHub (Nov 7, 2024): @rick-github It is preferable since the OpenAI related tools are usually well documented. When starting that pet project I was looking for an Ollama specific SDK for Go, but didn't find anything good at the time. My first thought was to check Ollama itself since it's probably using its own API from CLI. But I didn't find anything documented, only the sources and I didn't have much time to research how it works. If you can recommend a good library for Go to work with Ollama, please let me know. I'll check it out.
Author
Owner

@benjamine commented on GitHub (Jan 22, 2025):

this looks like a bug at this line:
294b6f5a22/server/routes.go (L1165)
gin is unescaping the %2F and thinking it's a subpath (resulting in 404). one possible solution is to use catch all like "/v1/models/*model" instead (and remove any leading slashes on the parameter)

<!-- gh-comment-id:2607571295 --> @benjamine commented on GitHub (Jan 22, 2025): this looks like a bug at this line: https://github.com/ollama/ollama/blob/294b6f5a220e8678c2b08fd2ab783a99e25c5215/server/routes.go#L1165 gin is unescaping the `%2F` and thinking it's a subpath (resulting in 404). one possible solution is to use catch all like `"/v1/models/*model"` instead (and remove any leading slashes on the parameter)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#66844