fix(google-genai): keep cost logging parameters in provider config

This commit is contained in:
Mingyang Wu 2026-09-11 16:46:48 +08:00
parent 36915da9c8
commit 38215a8a81
3 changed files with 10 additions and 2 deletions

View file

@ -17,7 +17,6 @@ from litellm.llms.base_llm.google_genai.transformation import (
BaseGoogleGenAIGenerateContentConfig,
)
from litellm.llms.custom_httpx.llm_http_handler import BaseLLMHTTPHandler
from litellm.llms.vertex_ai.vertex_llm_base import VertexBase
from litellm.types.router import GenericLiteLLMParams
from litellm.types.utils import CallTypes
from litellm.utils import ProviderConfigManager, client
@ -199,7 +198,7 @@ class GenerateContentHelper:
optional_params=dict(generate_content_config_dict),
litellm_params={
"litellm_call_id": litellm_call_id,
"vertex_location": VertexBase.explicit_vertex_ai_location(litellm_params.model_dump()),
**generate_content_provider_config.get_generate_content_logging_params(litellm_params),
},
custom_llm_provider=custom_llm_provider,
)

View file

@ -1,5 +1,6 @@
import types
from abc import ABC, abstractmethod
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any
import httpx
@ -73,6 +74,9 @@ class BaseGoogleGenAIGenerateContentConfig(ABC):
"""
return ("safetySettings", "toolConfig", "cachedContent", "labels")
def get_generate_content_logging_params(self, litellm_params: GenericLiteLLMParams) -> Mapping[str, object]:
return types.MappingProxyType({})
@abstractmethod
def map_generate_content_optional_params(
self,

View file

@ -2,6 +2,8 @@
Transformation for Calling Google models in their native format.
"""
from collections.abc import Mapping
from types import MappingProxyType
from typing import Any, Final, Literal
from litellm.llms.gemini.google_genai.transformation import GoogleGenAIConfig
@ -20,6 +22,9 @@ class VertexAIGoogleGenAIConfig(GoogleGenAIConfig):
def custom_llm_provider(self) -> Literal["gemini", "vertex_ai"]:
return "vertex_ai"
def get_generate_content_logging_params(self, litellm_params: GenericLiteLLMParams) -> Mapping[str, object]:
return MappingProxyType({"vertex_location": self.explicit_vertex_ai_location(litellm_params.model_dump())})
def validate_environment(
self,
api_key: str | None,