googleapis / googleapis/python-genai
google-genai SDK EmbedContentResponse Discards `usageMetadata` and Leaves `sdk_http_response.body` as None
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
`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))
```
Contributor guide
Assessment
This issue has not been assessed yet.