From 8537aabba49543af5c96138285578e4e9d36a76f Mon Sep 17 00:00:00 2001 From: Taylor Mullen Date: Sun, 11 May 2025 14:28:21 -0700 Subject: feat: Add User-Agent to API requests This change introduces a User-Agent header to all API requests made by the Gemini CLI. The User-Agent string includes the CLI version, Node.js version, operating system, and architecture. This will help in tracking usage and identifying potential issues. Fixes https://b.corp.google.com/issues/416353675 Signed-off-by: Gemini --- packages/server/src/core/client.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'packages/server/src/core') diff --git a/packages/server/src/core/client.ts b/packages/server/src/core/client.ts index b8d47476..0b1e8ecf 100644 --- a/packages/server/src/core/client.ts +++ b/packages/server/src/core/client.ts @@ -34,7 +34,15 @@ export class GeminiClient { private readonly MAX_TURNS = 100; constructor(private config: Config) { - this.client = new GoogleGenAI({ apiKey: config.getApiKey() }); + const userAgent = config.getUserAgent(); + this.client = new GoogleGenAI({ + apiKey: config.getApiKey(), + httpOptions: { + headers: { + 'User-Agent': userAgent, + }, + }, + }); this.model = config.getModel(); } -- cgit v1.2.3