Instead of only returning the payload of the response, we make sure that a proper Response object is constructed that includes the upstream API's response headers.
Added
Response headers are preserved for non-streaming chat completion requests.
Changed
Changed the response construction for non-streaming requests
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 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/open-webui/open-webui/pull/15412
**Author:** [@Simon-Stone](https://github.com/Simon-Stone)
**Created:** 7/1/2025
**Status:** ❌ Closed
**Base:** `dev` ← **Head:** `forward_response_headers`
---
### 📝 Commits (6)
- [`de018f0`](https://github.com/open-webui/open-webui/commit/de018f091260ae757a61e9e4d8691be6442e3ea6) refac
- [`55fb890`](https://github.com/open-webui/open-webui/commit/55fb89082fdec1634b1dfd8c9add064acbd718d5) forward response headers for non-streaming requests
- [`80975a3`](https://github.com/open-webui/open-webui/commit/80975a3edc7f71e0008ab28384e26c8dc79f5251) handle Response object
- [`b199894`](https://github.com/open-webui/open-webui/commit/b199894d51ffcf6bc8dcf854d6b57bb8ff4dd7c3) preserve old behavior if processed response is not a Response object
- [`9d5e132`](https://github.com/open-webui/open-webui/commit/9d5e132d06d69e9395dbd5b6e9b506d9118d878e) preserve return type
- [`3949535`](https://github.com/open-webui/open-webui/commit/3949535408c0e6db43e54c7b1e863fcfcf7c8d76) ensure Response object is turned into dict where needed
### 📊 Changes
**4 files changed** (+72 additions, -29 deletions)
<details>
<summary>View changed files</summary>
📝 `backend/open_webui/routers/openai.py` (+14 -5)
📝 `backend/open_webui/utils/middleware.py` (+58 -22)
📝 `backend/requirements.txt` (+0 -1)
📝 `pyproject.toml` (+0 -1)
</details>
### 📄 Description
# Changelog Entry
### Description
- Instead of only returning the payload of the response, we make sure that a proper `Response` object is constructed that includes the upstream API's response headers.
### Added
- Response headers are preserved for non-streaming chat completion requests.
### Changed
- Changed the response construction for non-streaming requests
### Fixed
- Fixes issue #15411
---
### Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/15412
Author: @Simon-Stone
Created: 7/1/2025
Status: ❌ Closed
Base:
dev← Head:forward_response_headers📝 Commits (6)
de018f0refac55fb890forward response headers for non-streaming requests80975a3handle Response objectb199894preserve old behavior if processed response is not a Response object9d5e132preserve return type3949535ensure Response object is turned into dict where needed📊 Changes
4 files changed (+72 additions, -29 deletions)
View changed files
📝
backend/open_webui/routers/openai.py(+14 -5)📝
backend/open_webui/utils/middleware.py(+58 -22)📝
backend/requirements.txt(+0 -1)📝
pyproject.toml(+0 -1)📄 Description
Changelog Entry
Description
Responseobject is constructed that includes the upstream API's response headers.Added
Changed
Fixed
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.