Files
litellm/tests
Tim Elfrink 9d7942eb35 Fix: Vertex AI Gemini labels field provider-aware filtering (#14563)
* Add comprehensive tests for Vertex AI Gemini labels provider filtering

- Test Google GenAI endpoints exclude labels even when explicitly provided
- Test Vertex AI endpoints include labels when provided
- Cover provider detection logic for different endpoint URLs
- Verify metadata-to-labels conversion only happens for Vertex AI
- Ensure edge cases are handled properly (null/empty api_base)

* Fix Vertex AI Gemini labels field provider-aware filtering

- Add _is_google_genai_endpoint() function to detect Google GenAI vs Vertex AI endpoints
- Update _transform_request_body() to accept api_base parameter
- Only include labels field for Vertex AI endpoints (not Google GenAI)
- Pass api_base through sync/async transform functions
- Maintain backward compatibility with existing usage
- Fixes issue where Google GenAI requests failed with unsupported labels field

* Refactor labels filtering to use custom_llm_provider instead of URL parsing

Replace URL-based endpoint detection with custom_llm_provider parameter
checking for cleaner, more reliable provider identification.

Changes:
- Remove _is_google_genai_endpoint() helper function
- Update labels condition to use custom_llm_provider != "gemini"
- Remove api_base parameter from _transform_request_body()
- Simplify sync/async transform function signatures
- Update tests to reflect new parameter structure
- Remove obsolete test_provider_detection test

This approach aligns with existing codebase patterns where
custom_llm_provider="gemini" identifies Google AI Studio endpoints
that don't support labels, while vertex_ai/vertex_ai_beta identify
Vertex AI endpoints that do support labels.

* Use LlmProviders.GEMINI constant instead of hardcoded string
2025-09-15 12:43:07 -07:00
..
2025-08-23 17:04:23 -07:00
2025-09-01 17:04:47 -07:00
2025-05-26 22:06:53 -07:00

In total litellm runs 1000+ tests

[02/20/2025] Update:

To make it easier to contribute and map what behavior is tested,

we've started mapping the litellm directory in tests/litellm

This folder can only run mock tests.