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
Merge origin/litellm_internal_staging into litellm_deterministic_output_file_ids
mateo-berri2434c1b904c7
diff --cc litellm/proxy/openai_files_endpoints/common_utils.pyindex 89c946cdea6,37b51e1d3af..080b8b80ae4--- a/litellm/proxy/openai_files_endpoints/common_utils.py+++ b/litellm/proxy/openai_files_endpoints/common_utils.py@@@ -894,6 -885,72 +896,68 @@@ def _extract_model_param(request: "Requ# ============================================================================+ def _batch_response_model_id_candidates(+ response,+ unified_batch_id: str | Literal[False] | None,+ ) -> tuple[str, ...]:+ response_id: Final = getattr(response, "id", None)+ decoded_response_id: Final = (+ _is_base64_encoded_unified_file_id(response_id) if isinstance(response_id, str) else False+ )+ return tuple(+ candidate+ for candidate in (+ unified_batch_id if isinstance(unified_batch_id, str) else None,+ decoded_response_id or None,+ response_id+ if isinstance(response_id, str)+ and not decoded_response_id+ and response_id.startswith(SpecialEnums.LITELM_MANAGED_FILE_ID_PREFIX.value)+ else None,+ )+ if candidate+ )+++ def _model_id_for_batch_response(+ response: "LiteLLMBatch",+ unified_batch_id: str | Literal[False] | None,+ ) -> str | None:+ hidden_params: Final = getattr(response, "_hidden_params", None) or {}+ model_id: Final = hidden_params.get("model_id")+ if model_id:+ return model_id+ return next(+ (+ candidate_model_id+ for candidate in _batch_response_model_id_candidates(response, unified_batch_id)+ if (candidate_model_id := get_model_id_from_unified_batch_id(candidate))+ ),+ None,+ )+++ def _model_name_for_batch_response(response: "LiteLLMBatch") -> str | None:+ hidden_params: Final = getattr(response, "_hidden_params", None) or {}- model_name: Final = hidden_params.get("model_name")- if model_name:- return model_name+ unified_file_id: Final = hidden_params.get("unified_file_id")- if not isinstance(unified_file_id, str):- return None- decoded_unified_file_id: Final = _is_base64_encoded_unified_file_id(unified_file_id) or unified_file_id- target_model_names: Final = get_models_from_unified_file_id(decoded_unified_file_id)- if target_model_names:- return ",".join(target_model_names)- return None++ return resolve_managed_output_file_model_name(++ unified_input_file_id=unified_file_id++ if isinstance(unified_file_id, str)++ else getattr(response, "input_file_id", None),++ fallback_model_name=hidden_params.get("model_name"),++ )+++ def _batch_owner_auth_from_db_object(db_batch_object: "LiteLLM_ManagedObjectTable") -> "UserAPIKeyAuth | None":+ from litellm.proxy._types import UserAPIKeyAuth++ created_by: Final = getattr(db_batch_object, "created_by", None)+ if not isinstance(created_by, str) or not created_by:+ return None+ raw_team_id: Final = getattr(db_batch_object, "team_id", None)+ return UserAPIKeyAuth(user_id=created_by, team_id=raw_team_id if isinstance(raw_team_id, str) else None)++async def resolve_input_file_id_to_unified(response, prisma_client) -> None:"""If the batch response contains a raw provider input_file_id (not already a