From d586ddc691eadb7f5d8eb390da8035e5cb6c30d9 Mon Sep 17 00:00:00 2001 From: zh Wang Date: Thu, 1 May 2025 00:51:05 +0800 Subject: [PATCH] [BugFix] Fix authorization of openai_transcription_client.py (#17321) Signed-off-by: zh Wang --- examples/online_serving/openai_transcription_client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/online_serving/openai_transcription_client.py b/examples/online_serving/openai_transcription_client.py index 5fcb7c526..66e622672 100644 --- a/examples/online_serving/openai_transcription_client.py +++ b/examples/online_serving/openai_transcription_client.py @@ -46,11 +46,15 @@ async def stream_openai_response(): "model": "openai/whisper-large-v3", } url = openai_api_base + "/audio/transcriptions" + headers = {"Authorization": f"Bearer {openai_api_key}"} print("transcription result:", end=' ') async with httpx.AsyncClient() as client: with open(str(winning_call), "rb") as f: - async with client.stream('POST', url, files={'file': f}, - data=data) as response: + async with client.stream('POST', + url, + files={'file': f}, + data=data, + headers=headers) as response: async for line in response.aiter_lines(): # Each line is a JSON object prefixed with 'data: ' if line: