feat(gemini): add X-Goog-Api-Client headers for API telemetry - #47385
Closed
vishal-dharm wants to merge 1 commit into
Closed
feat(gemini): add X-Goog-Api-Client headers for API telemetry#47385vishal-dharm wants to merge 1 commit into
vishal-dharm wants to merge 1 commit into
Conversation
Add `X-Goog-Api-Client` tracking headers and versioned `User-Agent` strings to Gemini API requests across native inference adapter, tier probes, and model probes. This follows the Gemini API partner integration guidelines (https://ai.google.dev/gemini-api/docs/partner-integration) and ensures hermes-agent traffic is correctly attributed in Google Generative Language API analytics. Header format: `hermes-agent/<version>` (e.g., `hermes-agent/0.16.0`)
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
x-goog-api-clienttracking headers and versionedUser-Agentstrings to Gemini API requests across the native inference adapter, tier probes, and model probes.This follows the Gemini API partner integration guidelines and ensures hermes-agent traffic is correctly attributed in Google Generative Language API analytics.
Changes
agent/gemini_native_adapter.pyhermes_cli.__version__with graceful fallbackx-goog-api-client: hermes-agent/<version>header to all inference requests (GeminiNativeClient._headers()) and tier probes (probe_gemini_tier())User-Agentstring:hermes-agent/<version> (gemini-native)hermes_cli/models.pyx-goog-api-client: hermes-agent/<version>header toprobe_api_models()tests/agent/test_gemini_native_adapter.pyHeader format
Follows the
company-product/versionconvention documented in the partner integration guidelines.How to test
PYTHONPATH=. pytest tests/agent/test_gemini_native_adapter.py -v -k "x_goog_api_client or user_agent_contains or hermes_version"All 4 new tests pass. All 19 pre-existing synchronous tests continue to pass.
Platforms tested