Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

[Feat] Add Azure AVA (Speech AI) Cost Tracking (#15754)

Ishaan Jaff92335d991cb4
diff --git a/docs/my-website/docs/providers/azure_ai_speech.md b/docs/my-website/docs/providers/azure_ai_speech.md
index 74c5c63e317..d358af4c6c8 100644
--- a/docs/my-website/docs/providers/azure_ai_speech.md
+++ b/docs/my-website/docs/providers/azure_ai_speech.md
@@ -54,6 +54,52 @@ model_list:
3. Note your region (e.g., `eastus`, `westus`, `westeurope`)
4. Use the regional endpoint: `https://{region}.tts.speech.microsoft.com`
+## Cost Tracking (Pricing)
+
+LiteLLM automatically tracks costs for Azure AI Speech based on the number of characters processed.
+
+### Available Models
+
+| Model | Voice Type | Cost per 1M Characters |
+|-------|-----------|----------------------|
+| `azure/speech/azure-tts` | Neural | $15 |
+| `azure/speech/azure-tts-hd` | Neural HD | $30 |
+
+### How Costs are Calculated
+
+Azure AI Speech charges based on the number of characters in your input text. LiteLLM automatically:
+- Counts the number of characters in your `input` parameter
+- Calculates the cost based on the model pricing
+- Returns the cost in the response object
+
+```python showLineNumbers title="View Request Cost"
+from litellm import speech
+
+response = speech(
+ model="azure/speech/azure-tts",
+ voice="alloy",
+ input="Hello, this is a test message",
+ api_base="https://eastus.tts.speech.microsoft.com",
+ api_key=os.environ["AZURE_TTS_API_KEY"],
+)
+
+# Access the calculated cost
+cost = response._hidden_params.get("response_cost")
+print(f"Request cost: ${cost}")
+```
+
+### Verify Azure Pricing
+
+To check the latest Azure AI Speech pricing:
+
+1. Visit the [Azure Pricing Calculator](https://azure.microsoft.com/en-us/pricing/calculator/)
+2. Set **Service** to "AI Services"
+3. Set **API** to "Azure AI Speech"
+4. Select **Text to Speech** and your region
+5. View the current pricing per million characters
+
+**Note:** Pricing may vary by region and Azure subscription type.
+
## Voice Mapping
LiteLLM automatically maps OpenAI voice names to Azure Neural voices:
diff --git a/docs/my-website/docs/text_to_speech.md b/docs/my-website/docs/text_to_speech.md
index de03f0381a9..2c6a3aa0589 100644
--- a/docs/my-website/docs/text_to_speech.md
+++ b/docs/my-website/docs/text_to_speech.md
@@ -4,6 +4,19 @@ import TabItem from '@theme/TabItem';
# /audio/speech
+## Overview
+
+| Feature | Supported | Notes |
+|-------|-------|-------|
+| Cost Tracking | ✅ | |
+| Logging | ✅ | works across all integrations |
+| End-user Tracking | ✅ | |
+| Fallbacks | ✅ | between supported models |
+| Loadbalancing | ✅ | between supported models |
+| Guardrails | ❌ Please make an [issue if you need this feature](https://github.com/BerriAI/litellm/issues/new) | |
+| Support llm providers | | `openai`, `azure`, `azure_ai`, `vertex_ai`, `gemini`, etc. |
+
+
## **LiteLLM Python SDK Usage**
### Quick Start
@@ -88,6 +101,7 @@ litellm --config /path/to/config.yaml
|-------------|--------------------|
| OpenAI | [Usage](#quick-start) |
| Azure OpenAI| [Usage](../docs/providers/azure#azure-text-to-speech-tts) |
+| Azure AI Speech Service (AVA)| [Usage](../docs/providers/azure_ai_speech) |
| Vertex AI | [Usage](../docs/providers/vertex#text-to-speech-apis) |
| Gemini | [Usage](#gemini-text-to-speech) |
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 255442d5cfb..25f4ea9ff90 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -2769,6 +2769,18 @@
"mode": "embedding",
"output_cost_per_token": 0.0
},
+ "azure/speech/azure-tts": {
+ "input_cost_per_character": 15e-06,
+ "litellm_provider": "azure",
+ "mode": "audio_speech",
+ "source": "https://azure.microsoft.com/en-us/pricing/calculator/"
+ },
+ "azure/speech/azure-tts-hd": {
+ "input_cost_per_character": 30e-06,
+ "litellm_provider": "azure",
+ "mode": "audio_speech",
+ "source": "https://azure.microsoft.com/en-us/pricing/calculator/"
+ },
"azure/tts-1": {
"input_cost_per_character": 1.5e-05,
"litellm_provider": "azure",
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 255442d5cfb..25f4ea9ff90 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -2769,6 +2769,18 @@
"mode": "embedding",
"output_cost_per_token": 0.0
},
+ "azure/speech/azure-tts": {
+ "input_cost_per_character": 15e-06,
+ "litellm_provider": "azure",
+ "mode": "audio_speech",
+ "source": "https://azure.microsoft.com/en-us/pricing/calculator/"
+ },
+ "azure/speech/azure-tts-hd": {
+ "input_cost_per_character": 30e-06,
+ "litellm_provider": "azure",
+ "mode": "audio_speech",
+ "source": "https://azure.microsoft.com/en-us/pricing/calculator/"
+ },
"azure/tts-1": {
"input_cost_per_character": 1.5e-05,
"litellm_provider": "azure",
diff --git a/tests/audio_tests/test_audio_speech.py b/tests/audio_tests/test_audio_speech.py
index 30e5fd5206a..8861686ab13 100644
--- a/tests/audio_tests/test_audio_speech.py
+++ b/tests/audio_tests/test_audio_speech.py
@@ -373,5 +373,9 @@ async def test_azure_ava_tts_async():
print(f"Azure TTS audio saved to: {speech_file_path}")
+ # assert response cost is greater than 0
+ print("Response cost: ", response._hidden_params["response_cost"])
+ assert response._hidden_params["response_cost"] > 0
+
except Exception as e:
pytest.fail(f"Test failed with exception: {str(e)}")