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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Litellm dev 12 26 2024 p3 (#7434)
Krish Dholakia9d82ff47937c
diff --git a/docs/my-website/docs/providers/groq.md b/docs/my-website/docs/providers/groq.mdindex 967b9d3d589..23393bcc825 100644--- a/docs/my-website/docs/providers/groq.md+++ b/docs/my-website/docs/providers/groq.md@@ -259,6 +259,99 @@ if tool_calls:print("second response\n", second_response)```+## Groq - Vision Example++Select Groq models support vision. Check out their [model list](https://console.groq.com/docs/vision) for more details.++<Tabs>+<TabItem value="sdk" label="SDK">++```python+from litellm import completion++import os+from litellm import completion++os.environ["GROQ_API_KEY"] = "your-api-key"++# openai call+response = completion(+ model = "groq/llama-3.2-11b-vision-preview",+ messages=[+ {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "What’s in this image?"+ },+ {+ "type": "image_url",+ "image_url": {+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ }+ }+ ]+ }+ ],+)++```++</TabItem>+<TabItem value="proxy" label="PROXY">++1. Add Groq models to config.yaml++```yaml+model_list:+ - model_name: groq-llama3-8b-8192 # Model Alias to use for requests+ litellm_params:+ model: groq/llama3-8b-8192+ api_key: "os.environ/GROQ_API_KEY" # ensure you have `GROQ_API_KEY` in your .env+```++2. Start Proxy++```bash+litellm --config config.yaml+```++3. Test it++```python+import os+from openai import OpenAI++client = OpenAI(+ api_key="sk-1234", # your litellm proxy api key+)++response = client.chat.completions.create(+ model = "gpt-4-vision-preview", # use model="llava-hf" to test your custom OpenAI endpoint+ messages=[+ {+ "role": "user",+ "content": [+ {+ "type": "text",+ "text": "What’s in this image?"+ },+ {+ "type": "image_url",+ "image_url": {+ "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"+ }+ }+ ]+ }+ ],+)++```+</TabItem>+</Tabs>+## Speech to Text - Whisper```python@@ -274,4 +367,5 @@ transcript = litellm.transcription()print("response=", transcript)-```\ No newline at end of file+```+diff --git a/litellm/integrations/prometheus.py b/litellm/integrations/prometheus.pyindex 5454c5fcb01..89a9b48137c 100644--- a/litellm/integrations/prometheus.py+++ b/litellm/integrations/prometheus.py@@ -3,7 +3,7 @@# On success, log events to Prometheusimport sysfrom datetime import datetime, timedelta-from typing import List, Optional+from typing import List, Optional, castfrom litellm._logging import print_verbose, verbose_loggerfrom litellm.integrations.custom_logger import CustomLogger@@ -37,16 +37,12 @@ class PrometheusLogger(CustomLogger):self.litellm_proxy_failed_requests_metric = Counter(name="litellm_proxy_failed_requests_metric",documentation="Total number of failed responses from proxy - the client did not get a success response from litellm proxy",- labelnames=[- "end_user",- "hashed_api_key",- "api_key_alias",- REQUESTED_MODEL,- "team",- "team_alias",- "user",- ]- + EXCEPTION_LABELS,+ labelnames=PrometheusMetricLabels.litellm_proxy_failed_requests_metric.value,+ )+ self.litellm_proxy_failed_requests_by_tag_metric = Counter(+ name="litellm_proxy_failed_requests_by_tag_metric",+ documentation="Total number of failed responses from proxy - the client did not get a success response from litellm proxy",+ labelnames=PrometheusMetricLabels.litellm_proxy_failed_requests_by_tag_metric.value,)self.litellm_proxy_total_requests_metric = Counter(@@ -55,6 +51,12 @@ class PrometheusLogger(CustomLogger):labelnames=PrometheusMetricLabels.litellm_proxy_total_requests_metric.value,)+ self.litellm_proxy_total_requests_by_tag_metric = Counter(+ name="litellm_proxy_total_requests_by_tag_metric",+ documentation="Total number of requests made to the proxy server - track number of client side requests by custom metadata tags",+ labelnames=PrometheusMetricLabels.litellm_proxy_total_requests_by_tag_metric.value,+ )+# request latency metricsself.litellm_request_total_latency_metric = Histogram("litellm_request_total_latency_metric",@@ -63,12 +65,25 @@ class PrometheusLogger(CustomLogger):buckets=LATENCY_BUCKETS,)+ self.litellm_request_total_latency_by_tag_metric = Histogram(+ "litellm_request_total_latency_by_tag_metric",+ "Total latency (seconds) for a request to LiteLLM by custom metadata tags",+ labelnames=PrometheusMetricLabels.litellm_request_total_latency_by_tag_metric.value,+ buckets=LATENCY_BUCKETS,+ )+self.litellm_llm_api_latency_metric = Histogram("litellm_llm_api_latency_metric","Total latency (seconds) for a models LLM API call",labelnames=PrometheusMetricLabels.litellm_llm_api_latency_metric.value,buckets=LATENCY_BUCKETS,)+ self.litellm_llm_api_latency_by_tag_metric = Histogram(+ "litellm_llm_api_latency_by_tag_metric",+ "Total latency (seconds) for a models LLM API call by custom metadata tags",+ labelnames=PrometheusMetricLabels.litellm_llm_api_latency_by_tag_metric.value,+ buckets=LATENCY_BUCKETS,+ )self.litellm_llm_api_time_to_first_token_metric = Histogram("litellm_llm_api_time_to_first_token_metric",@@ -301,22 +316,36 @@ class PrometheusLogger(CustomLogger):self.litellm_deployment_latency_per_output_token = Histogram(name="litellm_deployment_latency_per_output_token",documentation="LLM Deployment Analytics - Latency per output token",- labelnames=_logged_llm_labels + team_and_key_labels,+ labelnames=PrometheusMetricLabels.litellm_deployment_latency_per_output_token.value,+ )++ self.litellm_deployment_latency_per_output_token_by_tag = Histogram(+ name="litellm_deployment_latency_per_output_token_by_tag",+ documentation="LLM Deployment Analytics - Latency per output token by custom metadata tags",+ labelnames=PrometheusMetricLabels.litellm_deployment_latency_per_output_token_by_tag.value,)self.litellm_deployment_successful_fallbacks = Counter("litellm_deployment_successful_fallbacks","LLM Deployment Analytics - Number of successful fallback requests from primary model -> fallback model",- [REQUESTED_MODEL, "fallback_model"]- + team_and_key_labels- + EXCEPTION_LABELS,+ PrometheusMetricLabels.litellm_deployment_successful_fallbacks.value,+ )+ self.litellm_deployment_successful_fallbacks_by_tag = Counter(+ "litellm_deployment_successful_fallbacks_by_tag",+ "LLM Deployment Analytics - Number of successful fallback requests from primary model -> fallback model by custom metadata tags",+ PrometheusMetricLabels.litellm_deployment_successful_fallbacks_by_tag.value,)+self.litellm_deployment_failed_fallbacks = Counter("litellm_deployment_failed_fallbacks","LLM Deployment Analytics - Number of failed fallback requests from primary model -> fallback model",- [REQUESTED_MODEL, "fallback_model"]- + team_and_key_labels- + EXCEPTION_LABELS,+ PrometheusMetricLabels.litellm_deployment_failed_fallbacks.value,+ )++ self.litellm_deployment_failed_fallbacks_by_tag = Counter(+ "litellm_deployment_failed_fallbacks_by_tag",+ "LLM Deployment Analytics - Number of failed fallback requests from primary model -> fallback model by custom metadata tags",+ PrometheusMetricLabels.litellm_deployment_failed_fallbacks_by_tag.value,)self.litellm_llm_api_failed_requests_metric = Counter(@@ -336,15 +365,7 @@ class PrometheusLogger(CustomLogger):self.litellm_requests_metric = Counter(name="litellm_requests_metric",documentation="deprecated - use litellm_proxy_total_requests_metric. Total number of LLM calls to litellm - track total per API Key, team, user",- labelnames=[- "end_user",- "hashed_api_key",- "api_key_alias",- "model",- "team",- "team_alias",- "user",- ],+ labelnames=PrometheusMetricLabels.litellm_requests_metric.value,)except Exception as e:@@ -422,6 +443,7 @@ class PrometheusLogger(CustomLogger):user_api_team_alias=user_api_team_alias,user_id=user_id,response_cost=response_cost,+ enum_values=enum_values,)# input, output, total token metrics@@ -472,7 +494,7 @@ class PrometheusLogger(CustomLogger):# set x-ratelimit headersself.set_llm_deployment_success_metrics(- kwargs, start_time, end_time, output_tokens+ kwargs, start_time, end_time, enum_values, output_tokens)if (@@ -484,6 +506,14 @@ class PrometheusLogger(CustomLogger):)self.litellm_proxy_total_requests_metric.labels(**_labels).inc()+ for tag in enum_values.tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_proxy_total_requests_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_proxy_total_requests_by_tag_metric.labels(**_labels).inc()+def _increment_token_metrics(self,standard_logging_payload: StandardLoggingPayload,@@ -594,16 +624,14 @@ class PrometheusLogger(CustomLogger):user_api_team_alias: Optional[str],user_id: Optional[str],response_cost: float,+ enum_values: UserAPIKeyLabelValues,):- self.litellm_requests_metric.labels(- end_user_id,- user_api_key,- user_api_key_alias,- model,- user_api_team,- user_api_team_alias,- user_id,- ).inc()+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_requests_metric.value,+ enum_values=enum_values,+ )+ self.litellm_requests_metric.labels(**_labels).inc()+self.litellm_spend_metric.labels(end_user_id,user_api_key,@@ -716,6 +744,15 @@ class PrometheusLogger(CustomLogger):self.litellm_llm_api_latency_metric.labels(**_labels).observe(api_call_total_time_seconds)+ for tag in enum_values.tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_llm_api_latency_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_llm_api_latency_by_tag_metric.labels(**_labels).observe(+ api_call_total_time_seconds+ )# total request latencyif start_time is not None and isinstance(start_time, datetime):@@ -729,6 +766,16 @@ class PrometheusLogger(CustomLogger):total_time_seconds)+ for tag in enum_values.tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_request_total_latency_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_request_total_latency_by_tag_metric.labels(+ **_labels+ ).observe(total_time_seconds)+async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time):from litellm.types.utils import StandardLoggingPayload@@ -793,6 +840,7 @@ class PrometheusLogger(CustomLogger):] + EXCEPTION_LABELS,"""try:+ _tags = cast(List[str], request_data.get("tags") or [])enum_values = UserAPIKeyLabelValues(end_user=user_api_key_dict.end_user_id,user=user_api_key_dict.user_id,@@ -802,27 +850,37 @@ class PrometheusLogger(CustomLogger):team_alias=user_api_key_dict.team_alias,requested_model=request_data.get("model", ""),status_code=str(getattr(original_exception, "status_code", None)),+ exception_status=str(getattr(original_exception, "status_code", None)),exception_class=str(original_exception.__class__.__name__),+ tags=_tags,+ )+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_proxy_failed_requests_metric.value,+ enum_values=enum_values,)+ self.litellm_proxy_failed_requests_metric.labels(**_labels).inc()- self.litellm_proxy_failed_requests_metric.labels(- end_user=user_api_key_dict.end_user_id,- hashed_api_key=user_api_key_dict.api_key,- api_key_alias=user_api_key_dict.key_alias,- requested_model=request_data.get("model", ""),- team=user_api_key_dict.team_id,- team_alias=user_api_key_dict.team_alias,- user=user_api_key_dict.user_id,- exception_status=getattr(original_exception, "status_code", None),- exception_class=str(original_exception.__class__.__name__),- ).inc()+ for tag in _tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_proxy_failed_requests_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_proxy_failed_requests_by_tag_metric.labels(**_labels).inc()_labels = prometheus_label_factory(supported_enum_labels=PrometheusMetricLabels.litellm_proxy_total_requests_metric.value,enum_values=enum_values,)self.litellm_proxy_total_requests_metric.labels(**_labels).inc()- pass++ for tag in enum_values.tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_proxy_total_requests_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_proxy_total_requests_by_tag_metric.labels(**_labels).inc()except Exception as e:verbose_logger.exception("prometheus Layer Error(): Exception occured - {}".format(str(e))@@ -851,6 +909,14 @@ class PrometheusLogger(CustomLogger):enum_values=enum_values,)self.litellm_proxy_total_requests_metric.labels(**_labels).inc()++ for tag in enum_values.tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_proxy_total_requests_by_tag_metric.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_proxy_total_requests_by_tag_metric.labels(**_labels).inc()except Exception as e:verbose_logger.exception("prometheus Layer Error(): Exception occured - {}".format(str(e))@@ -962,6 +1028,7 @@ class PrometheusLogger(CustomLogger):request_kwargs: dict,start_time,end_time,+ enum_values: UserAPIKeyLabelValues,output_tokens: float = 1.0,):try:@@ -1092,21 +1159,12 @@ class PrometheusLogger(CustomLogger):latency_per_token = Noneif output_tokens is not None and output_tokens > 0:latency_per_token = _latency_seconds / output_tokens+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_deployment_latency_per_output_token.value,+ enum_values=enum_values,+ )self.litellm_deployment_latency_per_output_token.labels(- litellm_model_name=litellm_model_name,- model_id=model_id,- api_base=api_base,- api_provider=llm_provider,- hashed_api_key=standard_logging_payload["metadata"][- "user_api_key_hash"- ],- api_key_alias=standard_logging_payload["metadata"][- "user_api_key_alias"- ],- team=standard_logging_payload["metadata"]["user_api_key_team_id"],- team_alias=standard_logging_payload["metadata"][- "user_api_key_team_alias"- ],+ **_labels).observe(latency_per_token)except Exception as e:@@ -1142,7 +1200,8 @@ class PrometheusLogger(CustomLogger):))_new_model = kwargs.get("model")- self.litellm_deployment_successful_fallbacks.labels(+ _tags = cast(List[str], kwargs.get("tags") or [])+ enum_values = UserAPIKeyLabelValues(requested_model=original_model_group,fallback_model=_new_model,hashed_api_key=standard_metadata["user_api_key_hash"],@@ -1151,7 +1210,21 @@ class PrometheusLogger(CustomLogger):team_alias=standard_metadata["user_api_key_team_alias"],exception_status=str(getattr(original_exception, "status_code", None)),exception_class=str(original_exception.__class__.__name__),- ).inc()+ tags=_tags,+ )+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_deployment_successful_fallbacks.value,+ enum_values=enum_values,+ )+ self.litellm_deployment_successful_fallbacks.labels(**_labels).inc()++ for tag in _tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_deployment_successful_fallbacks_by_tag.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_deployment_successful_fallbacks_by_tag.labels(**_labels).inc()async def log_failure_fallback_event(self, original_model_group: str, kwargs: dict, original_exception: Exception@@ -1171,12 +1244,14 @@ class PrometheusLogger(CustomLogger):)_new_model = kwargs.get("model")_metadata = kwargs.get("metadata", {})+ _tags = cast(List[str], kwargs.get("tags") or [])standard_metadata: StandardLoggingMetadata = (StandardLoggingPayloadSetup.get_standard_logging_metadata(metadata=_metadata))- self.litellm_deployment_failed_fallbacks.labels(++ enum_values = UserAPIKeyLabelValues(requested_model=original_model_group,fallback_model=_new_model,hashed_api_key=standard_metadata["user_api_key_hash"],@@ -1185,7 +1260,22 @@ class PrometheusLogger(CustomLogger):team_alias=standard_metadata["user_api_key_team_alias"],exception_status=str(getattr(original_exception, "status_code", None)),exception_class=str(original_exception.__class__.__name__),- ).inc()+ tags=_tags,+ )++ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_deployment_failed_fallbacks.value,+ enum_values=enum_values,+ )+ self.litellm_deployment_failed_fallbacks.labels(**_labels).inc()++ for tag in _tags:+ _labels = prometheus_label_factory(+ supported_enum_labels=PrometheusMetricLabels.litellm_deployment_failed_fallbacks_by_tag.value,+ enum_values=enum_values,+ tag=tag,+ )+ self.litellm_deployment_failed_fallbacks_by_tag.labels(**_labels).inc()def set_litellm_deployment_state(self,@@ -1273,7 +1363,9 @@ class PrometheusLogger(CustomLogger):def prometheus_label_factory(- supported_enum_labels: List[str], enum_values: UserAPIKeyLabelValues+ supported_enum_labels: List[str],+ enum_values: UserAPIKeyLabelValues,+ tag: Optional[str] = None,) -> dict:"""Returns a dictionary of label + values for prometheus.@@ -1290,6 +1382,9 @@ def prometheus_label_factory(if label in supported_enum_labels}+ if tag and "tag" in supported_enum_labels:+ filtered_labels["tag"] = tag+if UserAPIKeyLabelNames.END_USER.value in filtered_labels:filtered_labels["end_user"] = get_end_user_id_for_cost_tracking(litellm_params={"user_api_key_end_user_id": enum_values.end_user},diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 3c09e6a7188..5f98c0e68b0 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -2119,7 +2119,8 @@"litellm_provider": "groq","mode": "chat","supports_function_calling": true,- "supports_response_schema": true+ "supports_response_schema": true,+ "supports_vision": true},"groq/llama-3.2-90b-text-preview": {"max_tokens": 8192,@@ -2141,7 +2142,8 @@"litellm_provider": "groq","mode": "chat","supports_function_calling": true,- "supports_response_schema": true+ "supports_response_schema": true,+ "supports_vision": true},"groq/llama3-70b-8192": {"max_tokens": 8192,diff --git a/litellm/types/integrations/prometheus.py b/litellm/types/integrations/prometheus.pyindex 52ef6a8a7be..395d9303701 100644--- a/litellm/types/integrations/prometheus.py+++ b/litellm/types/integrations/prometheus.py@@ -65,6 +65,7 @@ class UserAPIKeyLabelNames(Enum):EXCEPTION_STATUS = EXCEPTION_STATUSEXCEPTION_CLASS = EXCEPTION_CLASSSTATUS_CODE = "status_code"+ FALLBACK_MODEL = "fallback_model"class PrometheusMetricLabels(Enum):@@ -101,6 +102,92 @@ class PrometheusMetricLabels(Enum):UserAPIKeyLabelNames.STATUS_CODE.value,]+ litellm_proxy_failed_requests_metric = [+ UserAPIKeyLabelNames.END_USER.value,+ UserAPIKeyLabelNames.API_KEY_HASH.value,+ UserAPIKeyLabelNames.API_KEY_ALIAS.value,+ UserAPIKeyLabelNames.REQUESTED_MODEL.value,+ UserAPIKeyLabelNames.TEAM.value,+ UserAPIKeyLabelNames.TEAM_ALIAS.value,+ UserAPIKeyLabelNames.USER.value,+ UserAPIKeyLabelNames.EXCEPTION_STATUS.value,+ UserAPIKeyLabelNames.EXCEPTION_CLASS.value,+ ]++ litellm_proxy_failed_requests_by_tag_metric = (+ litellm_proxy_failed_requests_metric+ + [+ UserAPIKeyLabelNames.TAG.value,+ ]+ )++ litellm_request_total_latency_by_tag_metric = (+ litellm_request_total_latency_metric+ + [+ UserAPIKeyLabelNames.TAG.value,+ ]+ )++ litellm_llm_api_latency_by_tag_metric = litellm_llm_api_latency_metric + [+ UserAPIKeyLabelNames.TAG.value,+ ]++ litellm_deployment_latency_per_output_token = [+ UserAPIKeyLabelNames.v2_LITELLM_MODEL_NAME.value,+ UserAPIKeyLabelNames.MODEL_ID.value,+ UserAPIKeyLabelNames.API_BASE.value,+ UserAPIKeyLabelNames.API_PROVIDER.value,+ UserAPIKeyLabelNames.API_KEY_HASH.value,+ UserAPIKeyLabelNames.API_KEY_ALIAS.value,+ UserAPIKeyLabelNames.TEAM.value,+ UserAPIKeyLabelNames.TEAM_ALIAS.value,+ ]++ litellm_deployment_latency_per_output_token_by_tag = (+ litellm_deployment_latency_per_output_token+ + [+ UserAPIKeyLabelNames.TAG.value,+ ]+ )++ litellm_requests_metric = [+ UserAPIKeyLabelNames.END_USER.value,+ UserAPIKeyLabelNames.API_KEY_HASH.value,+ UserAPIKeyLabelNames.API_KEY_ALIAS.value,+ UserAPIKeyLabelNames.v1_LITELLM_MODEL_NAME.value,+ UserAPIKeyLabelNames.TEAM.value,+ UserAPIKeyLabelNames.TEAM_ALIAS.value,+ UserAPIKeyLabelNames.USER.value,+ ]++ litellm_proxy_total_requests_by_tag_metric = litellm_proxy_total_requests_metric + [+ UserAPIKeyLabelNames.TAG.value,+ ]++ litellm_deployment_successful_fallbacks = [+ UserAPIKeyLabelNames.REQUESTED_MODEL.value,+ UserAPIKeyLabelNames.FALLBACK_MODEL.value,+ UserAPIKeyLabelNames.API_KEY_HASH.value,+ UserAPIKeyLabelNames.API_KEY_ALIAS.value,+ UserAPIKeyLabelNames.TEAM.value,+ UserAPIKeyLabelNames.TEAM_ALIAS.value,+ UserAPIKeyLabelNames.EXCEPTION_STATUS.value,+ UserAPIKeyLabelNames.EXCEPTION_CLASS.value,+ ]++ litellm_deployment_successful_fallbacks_by_tag = (+ litellm_deployment_successful_fallbacks+ + [+ UserAPIKeyLabelNames.TAG.value,+ ]+ )++ litellm_deployment_failed_fallbacks = litellm_deployment_successful_fallbacks++ litellm_deployment_failed_fallbacks_by_tag = (+ litellm_deployment_successful_fallbacks_by_tag+ )+from typing import List, Optional@@ -124,6 +211,7 @@ class UserAPIKeyLabelValues(BaseModel):exception_status: Optional[str] = Noneexception_class: Optional[str] = Nonestatus_code: Optional[str] = None+ fallback_model: Optional[str] = Noneclass Config:fields = {@@ -142,4 +230,5 @@ class UserAPIKeyLabelValues(BaseModel):"exception_status": {"alias": UserAPIKeyLabelNames.EXCEPTION_STATUS},"exception_class": {"alias": UserAPIKeyLabelNames.EXCEPTION_CLASS},"status_code": {"alias": UserAPIKeyLabelNames.STATUS_CODE},+ "fallback_model": {"alias": UserAPIKeyLabelNames.FALLBACK_MODEL},}diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 3c09e6a7188..5f98c0e68b0 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -2119,7 +2119,8 @@"litellm_provider": "groq","mode": "chat","supports_function_calling": true,- "supports_response_schema": true+ "supports_response_schema": true,+ "supports_vision": true},"groq/llama-3.2-90b-text-preview": {"max_tokens": 8192,@@ -2141,7 +2142,8 @@"litellm_provider": "groq","mode": "chat","supports_function_calling": true,- "supports_response_schema": true+ "supports_response_schema": true,+ "supports_vision": true},"groq/llama3-70b-8192": {"max_tokens": 8192,diff --git a/tests/local_testing/test_gcs_bucket.py b/tests/local_testing/test_gcs_bucket.pyindex f0b11e6418d..fa5003ca7a4 100644--- a/tests/local_testing/test_gcs_bucket.py+++ b/tests/local_testing/test_gcs_bucket.py@@ -522,9 +522,9 @@ async def test_basic_gcs_logging_per_request_with_no_litellm_callback_set():)[email protected](retries=5, delay=3)[email protected](reason="This test is flaky")@pytest.mark.asyncio-async def test_get_gcs_logging_config_without_service_account():+async def test_aaaget_gcs_logging_config_without_service_account():"""Test the get_gcs_logging_config works for IAM auth on GCS1. Key based logging without a service accountdiff --git a/tests/logging_callback_tests/test_prometheus_unit_tests.py b/tests/logging_callback_tests/test_prometheus_unit_tests.pyindex 5ccbf5c02bf..407015067e7 100644--- a/tests/logging_callback_tests/test_prometheus_unit_tests.py+++ b/tests/logging_callback_tests/test_prometheus_unit_tests.py@@ -14,7 +14,7 @@ from prometheus_client import REGISTRY, CollectorRegistryimport litellmfrom litellm import completionfrom litellm._logging import verbose_logger-from litellm.integrations.prometheus import PrometheusLogger+from litellm.integrations.prometheus import PrometheusLogger, UserAPIKeyLabelValuesfrom litellm.llms.custom_httpx.http_handler import AsyncHTTPHandlerfrom litellm.types.utils import (StandardLoggingPayload,@@ -339,6 +339,16 @@ def test_increment_top_level_request_and_spend_metrics(prometheus_logger):- litellm_requests_metric is incremented by 1- litellm_spend_metric is incremented by the response cost in the standard logging payload"""+ standard_logging_payload = create_standard_logging_payload()+ enum_values = UserAPIKeyLabelValues(+ litellm_model_name=standard_logging_payload["model"],+ api_provider=standard_logging_payload["custom_llm_provider"],+ hashed_api_key=standard_logging_payload["metadata"]["user_api_key_hash"],+ api_key_alias=standard_logging_payload["metadata"]["user_api_key_alias"],+ team=standard_logging_payload["metadata"]["user_api_key_team_id"],+ team_alias=standard_logging_payload["metadata"]["user_api_key_team_alias"],+ **standard_logging_payload,+ )prometheus_logger.litellm_requests_metric = MagicMock()prometheus_logger.litellm_spend_metric = MagicMock()@@ -351,10 +361,17 @@ def test_increment_top_level_request_and_spend_metrics(prometheus_logger):user_api_team_alias="team_alias1",user_id="user1",response_cost=0.1,+ enum_values=enum_values,)prometheus_logger.litellm_requests_metric.labels.assert_called_once_with(- "user1", "key1", "alias1", "gpt-3.5-turbo", "team1", "team_alias1", "user1"+ end_user=None,+ user=None,+ hashed_api_key="test_hash",+ api_key_alias="test_alias",+ team="test_team",+ team_alias="test_team_alias",+ model="gpt-3.5-turbo",)prometheus_logger.litellm_requests_metric.labels().inc.assert_called_once()@@ -496,7 +513,7 @@ async def test_async_post_call_failure_hook(prometheus_logger):team="test_team",team_alias="test_team_alias",user="test_user",- exception_status=429,+ exception_status="429",exception_class="RateLimitError",)prometheus_logger.litellm_proxy_failed_requests_metric.labels().inc.assert_called_once()@@ -584,6 +601,16 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):"standard_logging_object": standard_logging_payload,}+ enum_values = UserAPIKeyLabelValues(+ litellm_model_name=standard_logging_payload["model"],+ api_provider=standard_logging_payload["custom_llm_provider"],+ hashed_api_key=standard_logging_payload["metadata"]["user_api_key_hash"],+ api_key_alias=standard_logging_payload["metadata"]["user_api_key_alias"],+ team=standard_logging_payload["metadata"]["user_api_key_team_id"],+ team_alias=standard_logging_payload["metadata"]["user_api_key_team_alias"],+ **standard_logging_payload,+ )+start_time = datetime.now()end_time = start_time + timedelta(seconds=1)output_tokens = 10@@ -594,6 +621,7 @@ def test_set_llm_deployment_success_metrics(prometheus_logger):start_time=start_time,end_time=end_time,output_tokens=output_tokens,+ enum_values=enum_values,)# Verify remaining requests metric@@ -780,6 +808,7 @@ def test_deployment_state_management(prometheus_logger):def test_increment_deployment_cooled_down(prometheus_logger):+prometheus_logger.litellm_deployment_cooled_down = MagicMock()prometheus_logger.increment_deployment_cooled_down(