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
style: trim comments on batch retrieve model group stamp
mateo-berri128cb114bdac
diff --git a/litellm/router.py b/litellm/router.pyindex c6c25b6be17..20c9018abee 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -6175,11 +6175,8 @@ class Router:kwargs=new_kwargs,function_name="aretrieve_batch",)- ## STAMP THE MODEL GROUP FOR SPEND TRACKING ##- # A batch is retrieved by id, so the request carries no model group of its- # own - only the deployment that answered knows it. Batch token usage lands- # on this retrieve call (the provider reports counts once the job finishes),- # so without this the tokens are logged under an empty model_group.+ # A batch is retrieved by id, so only the deployment that answered knows the+ # group, and batch token usage is logged on this retrieve call.model_group: Final = requested_model_group or model_name["model_name"]new_kwargs[metadata_variable_name].setdefault("model_group", model_group)new_kwargs.pop("custom_llm_provider", None)diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.pyindex 9b146092927..258d1c973d0 100644--- a/tests/test_litellm/test_router.py+++ b/tests/test_litellm/test_router.py@@ -958,22 +958,6 @@ async def test_arouter_aretrieve_batch():assert mock_aretrieve_batch.call_args.kwargs["api_base"] == "my-custom-base"-# ----------------------------------------------------------------------------# Batch retrieval has to attribute its tokens to a model group.-#-# Batch token usage is accounted on the *retrieve* call, not on create: a-# provider only reports token counts once the job finishes, so the usage is read-# off the completed batch's output file during retrieve logging, and that is the-# spend log row the tokens land on. A batch is retrieved by id, so the request-# carries no model and the router fans the lookup out across its deployments --# the group of the deployment that answered is the only one there is to stamp.-# Leaving it unset files every batch's tokens under an empty model_group, which-# is what /global/activity/model groups the spend logs by.-#-# The provider is faked at the HTTP boundary, so the retrieve call and the usage-# accounting that reads the output file both run for real.-# ----------------------------------------------------------------------------_BATCH_GROUP = "gemini-batch-group"_BATCH_DEPLOYMENT_MODEL = "openai/gpt-4o-mini"_BATCH_API_BASE = "http://localhost:4001/v1"