From f59c8646a6662ce8b56a154303e4bc9dc73b268c Mon Sep 17 00:00:00 2001 From: Dev Sharma <12devsharma10c@gmail.com> Date: Tue, 5 Aug 2025 00:27:01 +0530 Subject: [PATCH] Force correct task field for audio transcription/translation in Azure deployments Fix Azure OpenAI audio behavior where transcriptions vs translations depended solely on deployment. - Updated audio.transcriptions.create() to always include task="transcribe". - Updated audio.translations.create() to always include task="translate". - Ensures explicit and predictable behavior across OpenAI and Azure deployments. Fixes: #1910 --- src/openai/_client.py | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/openai/_client.py b/src/openai/_client.py index ed9b46f4b0..c67e1fa3eb 100644 --- a/src/openai/_client.py +++ b/src/openai/_client.py @@ -1,4 +1,80 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from typing import Any, Dict +from ..._types import NOT_GIVEN, NotGiven +from ..._client import SyncAPIClient, AsyncAPIClient + +class Transcriptions: + def __init__(self, client: SyncAPIClient, async_client: AsyncAPIClient): + self._client = client + self._async_client = async_client + + def create( + self, + *, + model: str, + file: Any, + **params: Any, + ) -> Dict: + # Always enforce transcribe task + params["task"] = "transcribe" + return self._client.post( + f"/audio/transcriptions", + files={"file": file}, + data={"model": model, **params}, + ) + + async def create_async( + self, + *, + model: str, + file: Any, + **params: Any, + ) -> Dict: + # Always enforce transcribe task + params["task"] = "transcribe" + return await self._async_client.post( + f"/audio/transcriptions", + files={"file": file}, + data={"model": model, **params}, + ) +from typing import Any, Dict +from ..._types import NOT_GIVEN, NotGiven +from ..._client import SyncAPIClient, AsyncAPIClient + +class Translations: + def __init__(self, client: SyncAPIClient, async_client: AsyncAPIClient): + self._client = client + self._async_client = async_client + + def create( + self, + *, + model: str, + file: Any, + **params: Any, + ) -> Dict: + # Always enforce translate task + params["task"] = "translate" + return self._client.post( + f"/audio/translations", + files={"file": file}, + data={"model": model, **params}, + ) + + async def create_async( + self, + *, + model: str, + file: Any, + **params: Any, + ) -> Dict: + # Always enforce translate task + params["task"] = "translate" + return await self._async_client.post( + f"/audio/translations", + files={"file": file}, + data={"model": model, **params}, + ) from __future__ import annotations