Skip to content

Fix #171: [Bug] STT: Azure OpenAI (Whisper) transcription returns 404...#206

Open
JiwaniZakir wants to merge 2 commits intodaggerhashimoto:masterfrom
JiwaniZakir:fix/171-bug-stt-azure-openai-whisper-transcript
Open

Fix #171: [Bug] STT: Azure OpenAI (Whisper) transcription returns 404...#206
JiwaniZakir wants to merge 2 commits intodaggerhashimoto:masterfrom
JiwaniZakir:fix/171-bug-stt-azure-openai-whisper-transcript

Conversation

@JiwaniZakir
Copy link
Copy Markdown

@JiwaniZakir JiwaniZakir commented Mar 31, 2026

Closes #171

What

Appends ?api-version=<version> to the Whisper transcription URL when the OPENAI_API_VERSION environment variable is set. No behavior change for standard OpenAI usage where this var is unset.

Why

Azure OpenAI endpoints require an api-version query parameter on every request. Without it, POST /api/transcribe returns 404 Resource not found. Previously, server/lib/constants.ts built OPENAI_WHISPER_URL as a bare string with no mechanism to append query params.

How

  • server/lib/constants.ts: Exports a new OPENAI_API_VERSION constant read from process.env.OPENAI_API_VERSION. OPENAI_WHISPER_URL is now conditionally constructed: if OPENAI_API_VERSION is non-empty, the URL becomes ${OPENAI_BASE_URL}/audio/transcriptions?api-version=${OPENAI_API_VERSION}; otherwise it falls back to the existing bare path. OPENAI_TTS_URL is unchanged as Azure TTS is not affected.
  • server/lib/constants.test.ts (new file): Three Vitest cases cover the three relevant states — var unset (no query string), var set (query string appended), and Azure base URL with version (full URL shape verified).

No changes to server/services/openai-whisper.ts were needed since it already imports OPENAI_WHISPER_URL directly from constants.ts.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🔧 Refactor / chore (no functional change)

Checklist

  • npm run lint passes
  • npm run build && npm run build:server succeeds
  • npm test -- --run passes
  • New features include tests
  • UI changes include a screenshot or screen recording

Screenshots

N/A

Summary by CodeRabbit

  • New Features

    • Enhanced transcription service configuration by adding support for customizable OpenAI API versions through environment variables, enabling flexible endpoint setup for various service deployments
  • Tests

    • Added comprehensive test coverage validating transcription URL construction across multiple configuration scenarios, including different API versions and base URL combinations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3b452f06-fa43-476f-8c52-1531b57d5b11

📥 Commits

Reviewing files that changed from the base of the PR and between c9ad1bd and ce2b2db.

📒 Files selected for processing (2)
  • server/lib/constants.test.ts
  • server/lib/constants.ts

📝 Walkthrough

Walkthrough

Added support for optional api-version query parameter to OpenAI Whisper transcription URLs via new OPENAI_API_VERSION environment variable, enabling compatibility with Azure OpenAI endpoints that require this parameter. Accompanying test file validates URL construction across three scenarios.

Changes

Cohort / File(s) Summary
URL Configuration
server/lib/constants.ts
Added OPENAI_API_VERSION constant from environment; updated OPENAI_WHISPER_URL to conditionally append ?api-version= query parameter when version is provided.
Configuration Tests
server/lib/constants.test.ts
New test suite validating OPENAI_WHISPER_URL construction with three scenarios: unset API version, set API version, and Azure-style endpoint with API version.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A whisper through the Azure sky,
With version tags we now comply,
No more 404 errors here,
The query param makes it clear,
Constants tested, endpoints shear! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly references issue #171 and summarizes the core bug fix: addressing the 404 error in Azure OpenAI Whisper transcription.
Description check ✅ Passed The PR description is comprehensive and follows the template structure with clear sections for What, Why, How, Type of Change, and Checklist.
Linked Issues check ✅ Passed The implementation fully addresses issue #171 by adding OPENAI_API_VERSION support and conditionally appending the api-version query parameter to satisfy Azure OpenAI requirements.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the Azure OpenAI Whisper 404 issue: new environment variable export, conditional URL construction, and comprehensive test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] STT: Azure OpenAI (Whisper) transcription returns 404 due to missing api-version

2 participants