Skip to content

Can not set connection and total timeout for aiohttp streaming requests #1899

@Harry-Kwon

Description

@Harry-Kwon

This is a client library issue where setting the "timeout" option in genai.Client's http_options raises an error, making it impossible to set both the toal and connection timeout using aiohttp.

Environment details

  • Programming language: Python
  • OS: Linux (affects all OSes)
  • Language runtime version: Python 3.12
  • Package version: 1.51.0

Steps to reproduce

  1. Make a streaming request with the following client options:
client = genai.Client(
    ...,
    http_options=types.HttpOptions(
        async_client_args={
            "timeout": aiohttp.ClientTimeout(
                total=600.0,
                connect=10.0,
            )
        }
    ),
)
  1. This raises an error
TypeError: aiohttp.client.ClientSession.request() got multiple values for keyword argument 'timeout'

This is due to the timeout field being hardcoded in the aiohttp_session request

timeout=aiohttp.ClientTimeout(total=http_request.timeout),

while also being unpacked in

**self._async_client_session_request_args,

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions