Skip to content

feat(gemini): add X-Goog-Api-Client headers for API telemetry - #47385

Closed
vishal-dharm wants to merge 1 commit into
NousResearch:mainfrom
vishal-dharm:feat/add-gemini-api-tracking
Closed

feat(gemini): add X-Goog-Api-Client headers for API telemetry#47385
vishal-dharm wants to merge 1 commit into
NousResearch:mainfrom
vishal-dharm:feat/add-gemini-api-tracking

Conversation

@vishal-dharm

Copy link
Copy Markdown
Contributor

Add x-goog-api-client tracking headers and versioned User-Agent strings 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.py

  • Import Hermes version from hermes_cli.__version__ with graceful fallback
  • Add x-goog-api-client: hermes-agent/<version> header to all inference requests (GeminiNativeClient._headers()) and tier probes (probe_gemini_tier())
  • Version the User-Agent string: hermes-agent/<version> (gemini-native)

hermes_cli/models.py

  • Add x-goog-api-client: hermes-agent/<version> header to probe_api_models()

tests/agent/test_gemini_native_adapter.py

  • Add 4 test cases verifying header presence, format, User-Agent versioning, and version resolution

Header format

x-goog-api-client: hermes-agent/0.16.0

Follows the company-product/version convention 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

  • Linux (Python 3.11.9)

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`)
@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/gemini Google Gemini (AI Studio, Cloud Code) P3 Low — cosmetic, nice to have labels Jun 16, 2026
@teknium1 teknium1 added telemetry Touches outbound telemetry, usage attribution, or analytics — needs opt-in gating before merge and removed telemetry Touches outbound telemetry, usage attribution, or analytics — needs opt-in gating before merge labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have provider/gemini Google Gemini (AI Studio, Cloud Code) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants