[PR #2476] [CLOSED] Add OpenAI /v1/models API support #9640

Closed
opened 2025-11-12 15:10:51 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/2476
Author: @keriati
Created: 2/13/2024
Status: Closed

Base: mainHead: main


📝 Commits (1)

  • a5f1997 add openai v1/models support

📊 Changes

3 files changed (+100 additions, -0 deletions)

View changed files

📝 openai/openai.go (+12 -0)
📝 server/routes.go (+59 -0)
📝 server/routes_test.go (+29 -0)

📄 Description

Add openaAI API v1/models endpoint compatibility.

See spec at: https://platform.openai.com/docs/api-reference/models/list

Personally I am not so sure about putting the ListModelsHandlerOpenAI method into the router file, however the original ollama ListModelsHandler function is also there.

I generally don't write go, so sorry for any weird things. Let me know what you think about this change.

Requested in #2430

Example usage:

❯ curl http://localhost:11434/v1/models | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   226  100   226    0     0  33776      0 --:--:-- --:--:-- --:--:--  110k
{
  "object": "list",
  "data": [
    {
      "id": "codegpt/deepseek-coder-1.3b-typescript:latest",
      "object": "model",
      "created": 1707753573,
      "owned_by": "ollama"
    },
    {
      "id": "deepseek-coder:6.7b",
      "object": "model",
      "created": 1705498161,
      "owned_by": "ollama"
    }
  ]
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/2476 **Author:** [@keriati](https://github.com/keriati) **Created:** 2/13/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`a5f1997`](https://github.com/ollama/ollama/commit/a5f1997cae0f28dbb79cb557e27378f891428dd4) add openai v1/models support ### 📊 Changes **3 files changed** (+100 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `openai/openai.go` (+12 -0) 📝 `server/routes.go` (+59 -0) 📝 `server/routes_test.go` (+29 -0) </details> ### 📄 Description Add openaAI API **v1/models** endpoint compatibility. See spec at: https://platform.openai.com/docs/api-reference/models/list Personally I am not so sure about putting the ListModelsHandlerOpenAI method into the router file, however the original ollama ListModelsHandler function is also there. I generally don't write go, so sorry for any weird things. Let me know what you think about this change. Requested in #2430 Example usage: ```shell ❯ curl http://localhost:11434/v1/models | jq % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 226 100 226 0 0 33776 0 --:--:-- --:--:-- --:--:-- 110k { "object": "list", "data": [ { "id": "codegpt/deepseek-coder-1.3b-typescript:latest", "object": "model", "created": 1707753573, "owned_by": "ollama" }, { "id": "deepseek-coder:6.7b", "object": "model", "created": 1705498161, "owned_by": "ollama" } ] } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-12 15:10:52 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#9640