EmbedContentResponse type has no usage_metadata field, so it seems that the field is discarded when it's returned from the API.
When instantiating types.HttpResponse, the SDK only passes headers=response.headers and completely omits the body argument.
Reproduction:
import json
import httpx
import google.genai
# Replace with your actual Gemini API key
API_KEY = "YOUR_GEMINI_API_KEY"
# 1. Inspect the SDK Response Object
client = google.genai.Client(api_key=API_KEY)
response = client.models.embed_content(
model="gemini-embedding-2",
contents="hello world",
)
print("=== 1. SDK Response Object ===")
print("Response fields: ", list(response.model_fields.keys()))
print("Response metadata: ", response.metadata)
print("sdk_http_response.body:", response.sdk_http_response.body)
print()
# 2. Inspect the Raw Wire Response from the Gemini API
print("=== 2. Raw Wire Response from Gemini API ===")
url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-embedding-2:embedContent?key={API_KEY}"
payload = {
"model": "models/gemini-embedding-2",
"content": {"parts": [{"text": "hello world"}]}
}
raw_resp = httpx.post(url, json=payload)
print(json.dumps(raw_resp.json(), indent=2))
EmbedContentResponsetype has nousage_metadatafield, so it seems that the field is discarded when it's returned from the API.When instantiating
types.HttpResponse, the SDK only passes headers=response.headers and completely omits the body argument.Reproduction: