Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

feat: Add support for per-request metadata/headers in GenerativeModel.generate_content. - #709

Open
mukeshgupta7 wants to merge 3 commits into
google-gemini:mainfrom
mukeshgupta7:main
Open

mukeshgupta7 wants to merge 3 commits into
google-gemini:mainfrom
mukeshgupta7:main

Conversation

@mukeshgupta7

Copy link
Copy Markdown

Description of the change

Modified the GenerativeModel.generate_content and GenerativeModel.generate_content_async method to accept an additional parameter extra_headers that would be passed to the underlying client method. This would allow users to set headers on a per-request basis while maintaining backward compatibility.

Added the required tests in test_generative_model.py and test_generative_model_async.py

Type of change

Feature request

Checklist

  • I have performed a self-review of my code.
  • I have added detailed comments to my code where applicable.
  • I have verified that my change does not break existing code.
  • My PR is based on the latest changes of the main branch (if unsure, please run git pull --rebase upstream main).
  • I am familiar with the Google Style Guide for the language I have coded in.
  • I have read through the Contributing Guide and signed the Contributor License Agreement.

@github-actions github-actions Bot added status:awaiting review PR awaiting review from a maintainer component:python sdk Issue/PR related to Python SDK labels Mar 9, 2025
@mukeshgupta7 mukeshgupta7 changed the title feat: Add support for per-request metadata/headers in GenerativeModel.generate_content https://github.com/google-gemini/generative-ai-python/issues/698 feat: Add support for per-request metadata/headers in GenerativeModel.generate_content. Mar 9, 2025
@Annhiluc Annhiluc added type:feature request New feature request/enhancement status:triaged Issue/PR triaged to the corresponding sub-team p3 labels Mar 27, 2025

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

component:python sdk Issue/PR related to Python SDK p3 status:awaiting review PR awaiting review from a maintainer status:triaged Issue/PR triaged to the corresponding sub-team type:feature request New feature request/enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants