litellm/tests/unit/llms/azure
Mateo Wang 0855b15bf3
fix(speech)!: use the provider api key get_llm_provider resolves (#39522)
* fix(speech): use the provider api key get_llm_provider resolves

speech() called get_llm_provider and then dropped its dynamic_api_key
everywhere except the logging params, so a TTS deployment whose credential
lives in a provider-specific env var fell through to OPENAI_API_KEY on the
openai-compatible branch and to AZURE_OPENAI_API_KEY / AZURE_API_KEY on the
azure branch, failing with a missing-credentials error naming variables the
admin never configured.

Fold dynamic_api_key into both branch key chains, right after an explicitly
passed api_key, so a provider-scoped key is used while an explicit one stays
authoritative.

* test(main): assert an explicit api_key still outranks the provider-scoped one in speech()

* test(main): hand recorded TTS headers across threads through a queue

* fix(speech): try the provider-scoped key last so working global keys keep priority

Putting get_llm_provider's key ahead of litellm.api_key, OPENAI_API_KEY and
AZURE_API_KEY broke TTS setups that already worked through a global key, and
let local-inference placeholders like fake-api-key outrank a real
OPENAI_API_KEY. The provider-scoped key is now the last fallback in both
speech key chains, so only callers that had no key at all change behavior

* fix(speech): keep the provider key first but skip local-inference placeholders

Trying the provider key last let OPENAI_API_KEY or AZURE_API_KEY go to a
hosted_vllm, deepinfra or azure_ai endpoint whose own key was configured,
which leaks the global credential and still fails the reported setup. The
provider key goes first again, matching completion() and transcription(),
and the fake-api-key / dummy-key placeholders get_llm_provider returns for
local-inference providers are skipped there, so a real OPENAI_API_KEY still
wins over them

* fix(speech): keep a deployment's Entra ID credentials ahead of the provider-scoped key

* fix(speech): keep Entra ID from env vars and token refresh ahead of the provider-scoped key

* fix(speech): count a request's Entra ID token ahead of the provider-scoped key

* fix(speech): keep the provider key next to an Azure AD token TTS never sends

* test(azure): type the parameters of the Entra ID auth detection test
2026-11-24 23:10:44 +00:00
..
batches test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
chat fix(llms): treat chat-latest and gpt-chat-latest as gpt-5 family models (#51151) 2026-11-24 04:02:51 -08:00
completion test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
decisions fix(decisions): accept OpenAI input_json content parts on /v1/decisions (#52805) 2026-11-20 13:33:36 -08:00
image_edit test(unit): add package markers to migrated unit test directories 2026-09-20 11:53:14 +00:00
image_generation refactor(images): remove dall-e-2 and dall-e-3 code paths (#48703) 2026-10-28 17:48:09 -07:00
live feat(realtime): serve Azure GPT-Live sessions on /v1/live/sessions (#53238) 2026-11-20 17:46:05 -08:00
passthrough fix(vllm): write spend log rows for /vllm passthrough calls to router models (#45733) 2026-10-14 12:40:48 -07:00
realtime feat(realtime): bill translation WebRTC calls by the time the call ran (#53548) 2026-11-22 00:25:53 -08:00
response fix(azure): send no api-version on Foundry project /openai/v1 Responses bases (#51767) 2026-11-14 05:24:12 -05:00
search fix(azure)!: answer 401 when Entra rejects the deployment's credential (#49863) 2026-11-04 20:44:55 +00:00
text_to_speech test: migrate SDK and proxy-booting legacy CircleCI tests to their tiers (#45758) 2026-10-11 00:17:21 -07:00
vector_stores fix(vector_stores): put azure vector store id before the api-version query on retrieve, update and delete (#48224) 2026-10-24 13:44:19 -07:00
videos test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
__init__.py test(unit): add package markers to migrated unit test directories 2026-09-20 11:53:14 +00:00
test_audio_transcriptions.py fix(transcription): log the clip duration as usage when the provider sends none (#53256) 2026-11-20 18:30:52 -08:00
test_azure.py test(azure): restore client session after extra headers test (#52815) 2026-11-19 08:27:46 +00:00
test_azure_common_utils.py fix(speech)!: use the provider api key get_llm_provider resolves (#39522) 2026-11-24 23:10:44 +00:00
test_azure_cost_calculation.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_azure_embedding.py test: migrate tests/llm_translation into unit, integration and e2e tiers (#45759) 2026-10-11 07:58:53 +00:00
test_azure_exception_mapping.py fix(exceptions): map upstream 403 to PermissionDeniedError for OpenAI-style providers (#52179) 2026-11-17 03:14:09 +00:00
test_azure_fine_tuning_api.py test: move tests/test_litellm/llms into tests/unit/llms (#43191) 2026-09-25 12:43:23 -07:00
test_azure_ptu_capacity.py feat(proxy): split Azure PTU deployments across teams with per-team PTU ceilings and PTU-hour reporting (#43043) 2026-10-15 18:44:30 +00:00
test_azure_speech_audio_transcription.py refactor(types): replace Any with proven types in 137 files (#44478) 2026-10-05 11:01:45 -07:00