[PR #1392] [MERGED] chat api endpoint #41817

Closed
opened 2026-04-24 21:38:18 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1392
Author: @BruceMacD
Created: 12/5/2023
Status: Merged
Merged: 12/5/2023
Merged by: @BruceMacD

Base: mainHead: brucemacd/chat


📝 Commits (2)

📊 Changes

9 files changed (+551 additions, -133 deletions)

View changed files

📝 README.md (+11 -0)
📝 api/client.go (+13 -0)
📝 api/types.go (+49 -21)
📝 docs/api.md (+136 -7)
📝 llm/llama.go (+33 -24)
📝 llm/llm.go (+1 -1)
📝 server/images.go (+68 -20)
📝 server/images_test.go (+4 -6)
📝 server/routes.go (+236 -54)

📄 Description

  • add a new /api/chat API endpoint that takes an array of message objects. This endpoint is an alternative to /api/generate.
  • deprecate generation context and template, but continue to support them
  • rebuild chat content from messages

This changes adds a /api/chat endpoint to the API which takes an array of messages. This makes modifying and tracking the history on the fly much simpler. It is an alternative to prompt/response.

context will continue to work as expected for now, but at some point in the future we may want to replace it completely with /api/chat.

curl -X POST http://localhost:11434/api/generate -d '{
    "model": "mistral",
    "prompt": "hello, how are you?"
}'

OR

### Basic generate request with messages
curl -X POST http://localhost:11434/api/chat -d '{
    "model": "mistral",
    "messages": [
        {
            "role": "user",
            "content": "why is the sky blue?"
        }
    ]
}'

resolves #981
resolves #1203


🔄 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/1392 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 12/5/2023 **Status:** ✅ Merged **Merged:** 12/5/2023 **Merged by:** [@BruceMacD](https://github.com/BruceMacD) **Base:** `main` ← **Head:** `brucemacd/chat` --- ### 📝 Commits (2) - [`c977aae`](https://github.com/ollama/ollama/commit/c977aaebcd0d67075a94a98aaf7fa2772e08412d) chat api - [`517140b`](https://github.com/ollama/ollama/commit/517140b161ab1af864984e8ac479a76fa2642bba) update docs ### 📊 Changes **9 files changed** (+551 additions, -133 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+11 -0) 📝 `api/client.go` (+13 -0) 📝 `api/types.go` (+49 -21) 📝 `docs/api.md` (+136 -7) 📝 `llm/llama.go` (+33 -24) 📝 `llm/llm.go` (+1 -1) 📝 `server/images.go` (+68 -20) 📝 `server/images_test.go` (+4 -6) 📝 `server/routes.go` (+236 -54) </details> ### 📄 Description - add a new `/api/chat` API endpoint that takes an array of `message` objects. This endpoint is an alternative to `/api/generate`. - deprecate generation context and template, but continue to support them - rebuild chat content from messages This changes adds a `/api/chat` endpoint to the API which takes an array of messages. This makes modifying and tracking the history on the fly much simpler. It is an alternative to prompt/response. `context` will continue to work as expected for now, but at some point in the future we may want to replace it completely with `/api/chat`. ``` curl -X POST http://localhost:11434/api/generate -d '{ "model": "mistral", "prompt": "hello, how are you?" }' OR ### Basic generate request with messages curl -X POST http://localhost:11434/api/chat -d '{ "model": "mistral", "messages": [ { "role": "user", "content": "why is the sky blue?" } ] }' ``` resolves #981 resolves #1203 --- <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-24 21:38:18 -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#41817