-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Problem Statement
Hey team, would it be possible to add the following client identification to the library to help us track usage origins better?
Proposed Solution
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
Alternative Solutions
No response
Additional Context
No response
Would you be willing to help implement this feature?
- Yes, I'd like to contribute
- No, I'm just suggesting
Metadata
Metadata
Assignees
Labels
No labels