fix(helicone): add Gemini/Vertex AI support to HeliconeLogger

- Add "gemini" to helicone_model_list so Gemini models are recognized
- Use /custom/v1/log endpoint for Gemini models instead of /oai/v1/log
- Set correct provider_url for Google's generativelanguage API
- Add unit test for Gemini model recognition

Previously, Gemini models were logged as "gpt-3.5-turbo" with OpenAI
as the provider, corrupting analytics. Now they log correctly with
their actual model name and CUSTOM provider.
This commit is contained in:
Chesars 2026-01-17 18:00:00 -03:00
parent 0959467699
commit 542abc0429
2 changed files with 28 additions and 0 deletions

View file

@ -11,6 +11,7 @@ class HeliconeLogger:
helicone_model_list = [
"gpt",
"claude",
"gemini",
"command-r",
"command-r-plus",
"command-light",
@ -151,6 +152,9 @@ class HeliconeLogger:
if "claude" in model:
url = f"{self.api_base}/anthropic/v1/log"
provider_url = "https://api.anthropic.com/v1/messages"
elif "gemini" in model:
url = f"{self.api_base}/custom/v1/log"
provider_url = "https://generativelanguage.googleapis.com/v1beta"
headers = {
"Authorization": f"Bearer {self.key}",
"Content-Type": "application/json",

View file

@ -162,3 +162,27 @@ def test_helicone_removes_otel_span_from_metadata():
assert result_metadata["other_metadata"] == "some_value"
print("✅ Test passed: litellm_parent_otel_span was successfully removed from metadata")
def test_helicone_gemini_model_in_list():
"""
Test that Gemini models are in the helicone_model_list and use the correct endpoint.
Fixes: https://github.com/BerriAI/litellm/issues/19093
"""
from litellm.integrations.helicone import HeliconeLogger
logger = HeliconeLogger()
# Test that "gemini" is in the model list
assert "gemini" in logger.helicone_model_list, "gemini should be in helicone_model_list"
# Test that gemini models are recognized (not replaced with gpt-3.5-turbo)
test_models = ["gemini-1.5-pro", "gemini-2.0-flash", "vertex_ai/gemini-1.5-flash"]
for model in test_models:
is_recognized = any(
accepted_model in model
for accepted_model in logger.helicone_model_list
)
assert is_recognized, f"{model} should be recognized by helicone_model_list"
print("✅ Test passed: Gemini models are properly supported in HeliconeLogger")