[PR #21282] feat: add OpenAI-compatible auth/header config support for STT/TTS #97046

Open
opened 2026-05-15 23:27:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21282
Author: @tariktalay
Created: 2/9/2026
Status: 🔄 Open

Base: devHead: feat/audio-openai-config-support


📝 Commits (2)

  • ab88034 feat(audio): add custom headers and multiple auth types support for OpenAI-compatible APIs
  • 3847f64 Fix Content-Type header handling for multipart requests.

📊 Changes

6 files changed (+344 additions, -116 deletions)

View changed files

📝 backend/open_webui/config.py (+24 -0)
📝 backend/open_webui/main.py (+4 -0)
📝 backend/open_webui/routers/audio.py (+56 -31)
📝 backend/open_webui/routers/openai.py (+7 -83)
📝 backend/open_webui/utils/headers.py (+92 -0)
📝 src/lib/components/admin/Settings/Audio.svelte (+161 -2)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.

This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

  • Add OpenAI-compatible auth/header config support to Audio STT/TTS via shared header/cookie handling.
  • Expose Audio OpenAI config in backend config state and Audio settings UI.
  • Ensure STT multipart transcription path does not force JSON content type.
  • Improve STT upload file-handle safety using context-managed file reads.

Added

  • AUDIO_STT_OPENAI_API_CONFIG persistent config.
  • AUDIO_TTS_OPENAI_API_CONFIG persistent config.
  • Audio settings UI controls for OpenAI auth type + custom headers (STT/TTS).

Changed

  • Audio STT/TTS OpenAI request preparation now uses shared get_headers_and_cookies.
  • OpenAI router auth/header utility consolidation via shared utility import path.

Deprecated

  • [List any deprecated functionality or features that have been removed]

Removed

  • Router-local duplicated header/auth utility code in OpenAI router (moved to shared utility usage).

Fixed

  • STT OpenAI-compatible multipart request compatibility (content-type/boundary behavior).
  • File descriptor safety in STT transcription upload request path.

Security

  • No direct security feature added, but auth mode handling is standardized via shared utility and existing auth flow logic.

Breaking Changes

  • BREAKING CHANGE: [List any breaking changes affecting compatibility or functionality]

Additional Information

Manual verification summary:

  1. STT OpenAI-compatible transcription with bearer auth works.
  2. STT custom headers from Audio settings are forwarded.
  3. STT multipart upload succeeds with OpenAI-compatible backend.

Automated tests:

  • Added targeted test coverage for:
    • get_headers_and_cookies auth modes and header behavior
    • STT transcription multipart header behavior
    • STT file-handle lifecycle safety

Screenshots or Videos

IMG_1675

2026-02-10 00:04:39.522 | DEBUG | python_multipart.multipart:callback:627 - Calling on_end with no data
2026-02-10 00:04:39.530 | INFO | open_webui.routers.files:upload_file_handler:225 - file.content_type: audio/mpeg True
2026-02-10 00:04:39.572 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:60033 - "POST /api/v1/files/?process=true HTTP/1.1" 200
2026-02-10 00:04:39.604 | INFO | open_webui.routers.audio:transcribe:1073 - transcribe: C:\Users\xxxx\Desktop\myprojects\mychat\backend\data\uploads/71661df1-a62d-46aa-a6be-79c933650210_ElevenLabs_2025-12-31T09_54_16_Mia - Clear, Steady and Warm_pvc_sp98_s50_sb75_se0_b_m2.mp3 {}
2026-02-10 00:04:39.637 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:60033 - "GET /api/v1/files/71661df1-a62d-46aa-a6be-79c933650210/process/status?stream=true HTTP/1.1" 200
Chunk paths: ['C:\Users\xxxx\Desktop\myprojects\mychat\backend\data\uploads/71661df1-a62d-46aa-a6be-79c933650210_ElevenLabs_2025-12-31T09_54_16_Mia - Clear, Steady and Warm_pvc_sp98_s50_sb75_se0_b_m2.mp3']
2026-02-10 00:04:40.695 | DEBUG | asyncio.proactor_events:init:633 - Using proactor: IocpProactor
2026-02-10 00:04:40.705 | DEBUG | open_webui.utils.oauth:get_oauth_token:982 - Token refresh needed for user f5c93653-d562-4c70-833f-xxxxx, provider oidc
2026-02-10 00:04:41.279 | DEBUG | open_webui.utils.oauth:_perform_token_refresh:1108 - Token refresh successful for provider oidc
2026-02-10 00:04:41.319 | INFO | open_webui.utils.oauth:_refresh_token:1020 - Successfully refreshed token for session bd787730-f089-4e22-8157-xxxxx
2026-02-10 00:04:41.358 | DEBUG | urllib3.connectionpool:_new_conn:1049 - Starting new HTTPS connection (1): mygateway:443
2026-02-10 00:04:51.651 | DEBUG | urllib3.connectionpool:_make_request:544 - https://mygateway:443 "POST /xxx/stt/v1/audio/transcriptions HTTP/1.1" 200 996

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/21282 **Author:** [@tariktalay](https://github.com/tariktalay) **Created:** 2/9/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feat/audio-openai-config-support` --- ### 📝 Commits (2) - [`ab88034`](https://github.com/open-webui/open-webui/commit/ab880347d524fccb3b43da0f1a11fb9a77e371af) feat(audio): add custom headers and multiple auth types support for OpenAI-compatible APIs - [`3847f64`](https://github.com/open-webui/open-webui/commit/3847f6428de0b34d48779a69d01b9b18da549066) Fix `Content-Type` header handling for multipart requests. ### 📊 Changes **6 files changed** (+344 additions, -116 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/config.py` (+24 -0) 📝 `backend/open_webui/main.py` (+4 -0) 📝 `backend/open_webui/routers/audio.py` (+56 -31) 📝 `backend/open_webui/routers/openai.py` (+7 -83) 📝 `backend/open_webui/utils/headers.py` (+92 -0) 📝 `src/lib/components/admin/Settings/Audio.svelte` (+161 -2) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request. This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Take this as an opportunity to **make screenshots of the feature/fix and include it in the PR description**. - [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **BREAKING CHANGE**: Significant changes that may affect compatibility - **build**: Changes that affect the build system or external dependencies - **ci**: Changes to our continuous integration processes or workflows - **chore**: Refactor, cleanup, or other non-functional code changes - **docs**: Documentation update or addition - **feat**: Introduces a new feature or enhancement to the codebase - **fix**: Bug fix or error correction - **i18n**: Internationalization or localization changes - **perf**: Performance improvement - **refactor**: Code restructuring for better maintainability, readability, or scalability - **style**: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.) - **test**: Adding missing tests or correcting existing tests - **WIP**: Work in progress, a temporary label for incomplete or ongoing work # Changelog Entry ### Description - Add OpenAI-compatible auth/header config support to Audio STT/TTS via shared header/cookie handling. - Expose Audio OpenAI config in backend config state and Audio settings UI. - Ensure STT multipart transcription path does not force JSON content type. - Improve STT upload file-handle safety using context-managed file reads. ### Added - `AUDIO_STT_OPENAI_API_CONFIG` persistent config. - `AUDIO_TTS_OPENAI_API_CONFIG` persistent config. - Audio settings UI controls for OpenAI auth type + custom headers (STT/TTS). ### Changed - Audio STT/TTS OpenAI request preparation now uses shared `get_headers_and_cookies`. - OpenAI router auth/header utility consolidation via shared utility import path. ### Deprecated - [List any deprecated functionality or features that have been removed] ### Removed - Router-local duplicated header/auth utility code in OpenAI router (moved to shared utility usage). ### Fixed - STT OpenAI-compatible multipart request compatibility (content-type/boundary behavior). - File descriptor safety in STT transcription upload request path. ### Security - No direct security feature added, but auth mode handling is standardized via shared utility and existing auth flow logic. ### Breaking Changes - **BREAKING CHANGE**: [List any breaking changes affecting compatibility or functionality] --- ### Additional Information - Related discussion: https://github.com/open-webui/open-webui/discussions/20953 - Related issue: https://github.com/open-webui/open-webui/issues/21281 - Tested with self-hosted OpenAI-compatible vLLM service behind a gateway. Manual verification summary: 1. STT OpenAI-compatible transcription with bearer auth works. 2. STT custom headers from Audio settings are forwarded. 3. STT multipart upload succeeds with OpenAI-compatible backend. Automated tests: - Added targeted test coverage for: - `get_headers_and_cookies` auth modes and header behavior - STT transcription multipart header behavior - STT file-handle lifecycle safety ### Screenshots or Videos ![IMG_1675](https://github.com/user-attachments/assets/6278278e-ec4a-4b06-82f5-4ea520694f0e) 2026-02-10 00:04:39.522 | DEBUG | python_multipart.multipart:callback:627 - Calling on_end with no data 2026-02-10 00:04:39.530 | INFO | open_webui.routers.files:upload_file_handler:225 - file.content_type: audio/mpeg True 2026-02-10 00:04:39.572 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:60033 - "POST /api/v1/files/?process=true HTTP/1.1" 200 2026-02-10 00:04:39.604 | INFO | open_webui.routers.audio:transcribe:1073 - transcribe: C:\Users\xxxx\Desktop\myprojects\mychat\backend\data\uploads/71661df1-a62d-46aa-a6be-79c933650210_ElevenLabs_2025-12-31T09_54_16_Mia - Clear, Steady and Warm_pvc_sp98_s50_sb75_se0_b_m2.mp3 {} 2026-02-10 00:04:39.637 | INFO | uvicorn.protocols.http.httptools_impl:send:483 - 127.0.0.1:60033 - "GET /api/v1/files/71661df1-a62d-46aa-a6be-79c933650210/process/status?stream=true HTTP/1.1" 200 Chunk paths: ['C:\Users\xxxx\Desktop\myprojects\mychat\backend\data\uploads/71661df1-a62d-46aa-a6be-79c933650210_ElevenLabs_2025-12-31T09_54_16_Mia - Clear, Steady and Warm_pvc_sp98_s50_sb75_se0_b_m2.mp3'] 2026-02-10 00:04:40.695 | DEBUG | asyncio.proactor_events:init:633 - Using proactor: IocpProactor 2026-02-10 00:04:40.705 | DEBUG | open_webui.utils.oauth:get_oauth_token:982 - Token refresh needed for user f5c93653-d562-4c70-833f-xxxxx, provider oidc 2026-02-10 00:04:41.279 | DEBUG | open_webui.utils.oauth:_perform_token_refresh:1108 - Token refresh successful for provider oidc 2026-02-10 00:04:41.319 | INFO | open_webui.utils.oauth:_refresh_token:1020 - Successfully refreshed token for session bd787730-f089-4e22-8157-xxxxx 2026-02-10 00:04:41.358 | DEBUG | urllib3.connectionpool:_new_conn:1049 - Starting new HTTPS connection (1): mygateway:443 2026-02-10 00:04:51.651 | DEBUG | urllib3.connectionpool:_make_request:544 - [https://mygateway:443](https://mygateway/) "POST /xxx/stt/v1/audio/transcriptions HTTP/1.1" 200 996 ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-05-15 23:27:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#97046