-
Notifications
You must be signed in to change notification settings - Fork 697
Description
Summary
InlinedResponse is missing the metadata field that is documented in the REST API and present in InlinedRequest. This prevents users from tracking custom identifiers through batch processing. The metadata is accepted when submitting requests but cannot be retrieved from responses.
Environment details
- Programming language: Python
- OS: macOS (also reproducible on Linux)
- Language runtime version: Python 3.12.9
- Package version: google-genai 1.56.0
Steps to reproduce
- Create a batch job with metadata attached to inline requests:
from google import genai
client = genai.Client(api_key="...")
inline_requests = [
{
"contents": [{"parts": [{"text": "Hello"}], "role": "user"}],
"config": {"temperature": 0.5},
"metadata": {"request_id": "req-001", "batch_idx": "0"}
}
]
batch_job = client.batches.create(model="gemini-2.0-flash", src=inline_requests)- Wait for batch to complete, then retrieve results:
batch_job = client.batches.get(name=batch_job.name)
for resp in batch_job.dest.inlined_responses:
print(resp.metadata) # AttributeError: 'InlinedResponse' object has no attribute 'metadata'-
Expected:
resp.metadatareturns{"request_id": "req-001", "batch_idx": "0"} -
Actual:
AttributeError- themetadatafield is not defined onInlinedResponse
Additional context
The REST API documentation shows InlinedResponse should include a metadata field:
{
"metadata": { object },
"response": { object (GenerateContentResponse) },
"error": { object (Status) }
}However, InlinedResponse in types.py only defines response and error. Additionally, _InlinedResponse_from_mldev in batches.py doesn't copy the metadata field from the raw API response.
Note: InlinedRequest correctly includes the metadata field - it's only missing from InlinedResponse.