[PR #319] [CLOSED] RFC: optional generate header to not stream response #56794

Closed
opened 2026-04-29 11:22:05 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/319
Author: @BruceMacD
Created: 8/10/2023
Status: Closed

Base: mainHead: brucemacd/no-stream


📝 Commits (1)

  • 5147bb8 optional generate header to not stream response

📊 Changes

1 file changed (+17 additions, -0 deletions)

View changed files

📝 server/routes.go (+17 -0)

📄 Description

Add an optional request header to the generate endpoint that returns the full response in one JSON body, rather than streaming:

curl -X POST -H "Content-Type: application/json" -H "X-Streamed: false" -d '{
    "model": "llama2",
    "prompt": "why is the sky blue?"
}' 'localhost:11434/api/generate'

The issue suggests setting the Content-Type header to application/json to indicate the result should not be streamed, but thats not quite right since the content-type indicates the type of content in the request, rather than the response.

We also can't use the Accept: application/json, this indicates the response that is expected, but clients would also use Accept: application/json in the case of a streaming response, because the returned objects will be json.

resolves #281


🔄 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/319 **Author:** [@BruceMacD](https://github.com/BruceMacD) **Created:** 8/10/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `brucemacd/no-stream` --- ### 📝 Commits (1) - [`5147bb8`](https://github.com/ollama/ollama/commit/5147bb8cf25df850f7c54f6781fead5055323544) optional generate header to not stream response ### 📊 Changes **1 file changed** (+17 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `server/routes.go` (+17 -0) </details> ### 📄 Description Add an optional request header to the generate endpoint that returns the full response in one JSON body, rather than streaming: ``` curl -X POST -H "Content-Type: application/json" -H "X-Streamed: false" -d '{ "model": "llama2", "prompt": "why is the sky blue?" }' 'localhost:11434/api/generate' ``` The issue suggests setting the `Content-Type` header to `application/json` to indicate the result should not be streamed, but thats not quite right since the content-type indicates the type of content in the request, rather than the response. We also can't use the `Accept: application/json`, this indicates the response that is expected, but clients would also use `Accept: application/json` in the case of a streaming response, because the returned objects will be json. resolves #281 --- <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-29 11:22:05 -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#56794