[PR #5007] [MERGED] OpenAI: /v1/models and /v1/models/{model} compatibility #11640

Closed
opened 2026-04-12 23:34:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/5007
Author: @royjhan
Created: 6/12/2024
Status: Merged
Merged: 7/2/2024
Merged by: @royjhan

Base: mainHead: royh-openai


📝 Commits (10+)

📊 Changes

6 files changed (+386 additions, -13 deletions)

View changed files

📝 api/types.go (+7 -0)
📝 docs/openai.md (+1 -0)
📝 openai/openai.go (+149 -12)
openai/openai_test.go (+170 -0)
📝 server/routes.go (+3 -1)
📝 server/routes_test.go (+56 -0)

📄 Description

This PR adds compatibility with the /v1/models and /v1/models/{model} endpoint for listing models.

E.g.

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

{
  "object": "list",
  "data": [
    {
      "id": "mario:latest",
      "object": "model",
      "created": 1718141294,
      "owned_by": "ollama"
    },
    {
      "id": "nomic-embed-text:latest",
      "object": "model",
      "created": 1718054969,
      "owned_by": "ollama"
    },
    {
      "id": "llava:latest",
      "object": "model",
      "created": 1718049682,
      "owned_by": "ollama"
    },
    {
      "id": "mistral:latest",
      "object": "model",
      "created": 1717609491,
      "owned_by": "ollama"
    },
    {
      "id": "llama3:latest",
      "object": "model",
      "created": 1717451603,
      "owned_by": "ollama"
    }
  ]
}

Resolves #2430
Resolves #2476

Includes #5028


🔄 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/5007 **Author:** [@royjhan](https://github.com/royjhan) **Created:** 6/12/2024 **Status:** ✅ Merged **Merged:** 7/2/2024 **Merged by:** [@royjhan](https://github.com/royjhan) **Base:** `main` ← **Head:** `royh-openai` --- ### 📝 Commits (10+) - [`cb6d5b0`](https://github.com/ollama/ollama/commit/cb6d5b0310ae2c245c7e4f0cf3f85676789b9c7e) OpenAI v1 models - [`1114d96`](https://github.com/ollama/ollama/commit/1114d9661bc0cee5aaa1e9f7f6e24aee12e6c6fe) Refactor Writers - [`e57f0d1`](https://github.com/ollama/ollama/commit/e57f0d19f389d46e88441466ed6e1fc3870f9020) Add Test - [`310940d`](https://github.com/ollama/ollama/commit/310940d11e56232d7c6220dc809fef894b0c0618) Credit Co-Author - [`691e448`](https://github.com/ollama/ollama/commit/691e44869e3f463a79be6137b11e8780fde3d24d) Merge branch 'main' into royh-openai - [`65c0850`](https://github.com/ollama/ollama/commit/65c08507cb55839709da2db0f7dad65bb2133485) Empty List Testing - [`c826421`](https://github.com/ollama/ollama/commit/c826421f17ea2a3b351a9da18e36a993b0856a33) Use Namespace for Ownedby - [`fe1a625`](https://github.com/ollama/ollama/commit/fe1a625fee3c2b663c7814042392135fc9bdd973) Update Test - [`3cf19d9`](https://github.com/ollama/ollama/commit/3cf19d95880cbd16073733622c9fe505050baf02) Add back envconfig - [`c037616`](https://github.com/ollama/ollama/commit/c037616d6bbecf91ec87a84336bac45f07846fe5) v1/models docs ### 📊 Changes **6 files changed** (+386 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+7 -0) 📝 `docs/openai.md` (+1 -0) 📝 `openai/openai.go` (+149 -12) ➕ `openai/openai_test.go` (+170 -0) 📝 `server/routes.go` (+3 -1) 📝 `server/routes_test.go` (+56 -0) </details> ### 📄 Description This PR adds compatibility with the /v1/models and /v1/models/{model} endpoint for listing models. E.g. `curl http://localhost:11434/v1/models` ``` { "object": "list", "data": [ { "id": "mario:latest", "object": "model", "created": 1718141294, "owned_by": "ollama" }, { "id": "nomic-embed-text:latest", "object": "model", "created": 1718054969, "owned_by": "ollama" }, { "id": "llava:latest", "object": "model", "created": 1718049682, "owned_by": "ollama" }, { "id": "mistral:latest", "object": "model", "created": 1717609491, "owned_by": "ollama" }, { "id": "llama3:latest", "object": "model", "created": 1717451603, "owned_by": "ollama" } ] } ``` Resolves #2430 Resolves #2476 Includes #5028 --- <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 2026-04-12 23:34:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#11640