Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Client identification for Gemini API #19

Copy link
Copy link
@thorwebdev

Description

@thorwebdev
Issue body actions

Hey team, would it be possible to add the following client identification to the library to help us track usage origins better?

X-Goog-Api-Client: API client identification. The value is a space-separated list of NAME "/" SEMVER strings, where the NAME should only contain lowercase letters, digits, and "-", and the SEMVER should be a semantic version string. For example: X-Goog-Api-Client: python/3.5.0 grpc-google-pubsub-v1/0.1.0-beta2 linux/2.7.0.

See system parameter docs here: https://docs.cloud.google.com/apis/docs/system-parameters

Example: 
## Python:

from google import genai

client = genai.Client(
    api_key="...",
    http_options={
        "headers": {
            "x-goog-api-client": "my-sdk-py/1.23",
        }
    }
)

## JavaScript
import { GoogleGenAI } from '@google/genai';

const ai = new GoogleGenAI({
    apiKey: '...',
    httpOptions: {
        headers: {
            'x-goog-api-client': 'my-sdk-js/1.23'
        }
    }
});

## Direct API
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json'
    -H 'X-Goog-Api-Client: my-sdk/1.23'
    -d '{...}'

You can see an example implementation of that client identification in the SDK here: https://github.com/google/adk-python/blob/main/src/google/adk/models/google_llm.py#L262-L272

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.