Skip to content

Allow specification of timeout variable for GenerativeModel.generate_content and GenerativeModel.generate_content_async #182

@spencermyoung513

Description

@spencermyoung513

Description of the feature request:

Currently, when making a request to the Gemini Pro Vision API via GenerativeModel.generate_content or GenerativeModel.generate_content_async, there is no easy way to change the default timeout value on the request. It would be great to have this as a parameter (perhaps just as a non-documented kwarg) in the generate_content and other sibling methods.

What problem are you trying to solve with this feature?

Sometimes, API requests with multiple images or lots of tokens take longer than 60 seconds to get a response. But with a hard-enforced timeout setting of 60 seconds, these requests fail no matter what.

Any other information you'd like to share?

For the GenerativeServiceAsyncClient, at least, timeout is a parameter of many methods like generate_content. It is not a parameter of the GenerativeModel.generate_content method (or any of its siblings), however.

This could be amended currently by creating a custom client class that inherits from, say, GenerativeServiceAsyncClient and overriding the internal _client or _async_client attributes of a GenerativeModel. Such a workaround is far from elegant though, and creates a lot of pain on the developer side.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions