Environment details
───────────────────
• Programming language: Python
• OS: Windows
• Language runtime version: 3.13.3
• Package version: google-genai 2.5.0, aiohttp 3.13.3
Steps to reproduce
──────────────────
-
Install google-genai and aiohttp in the same environment:
pip install google-genai==2.5.0 aiohttp==3.13.3
-
Run any async streaming request:
import asyncio
from google import genai
async def main():
client = genai.Client(api_key="YOUR_API_KEY")
async for chunk in client.aio.models.generate_content_stream(
model="gemini-3.5-flash",
contents="Hello"
):
print(chunk)
asyncio.run(main())
-
The request crashes immediately with:
TypeError: StreamReader.readline() got an unexpected keyword argument 'max_line_length'
Root cause
──────────
In google/genai/_api_client.py around line 450, the library calls:
line_bytes = await self.response_stream.content.readline(
max_line_length=READ_BUFFER_SIZE
)
However, aiohttp.StreamReader.readline() does not accept any parameters. Its signature is simply:
async def readline(self) -> bytes:
return await self.readuntil()
The max_line_length keyword argument was introduced in PR #2437, but it is incompatible with the actual aiohttp API.
The line-length limit is already governed by the limit parameter of StreamReader,
which is set correctly via read_bufsize=READ_BUFFER_SIZE (4MB) when the aiohttp
ClientSession is created:
https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py#L958
Suggested fix
─────────────
Remove the unsupported max_line_length keyword argument:
line_bytes = await self.response_stream.content.readline()
The existing read_bufsize configuration already prevents LineTooLong errors for large SSE lines.
Environment details
───────────────────
• Programming language: Python
• OS: Windows
• Language runtime version: 3.13.3
• Package version: google-genai 2.5.0, aiohttp 3.13.3
Steps to reproduce
──────────────────
Install google-genai and aiohttp in the same environment:
pip install google-genai==2.5.0 aiohttp==3.13.3
Run any async streaming request:
import asyncio
from google import genai
async def main():
client = genai.Client(api_key="YOUR_API_KEY")
async for chunk in client.aio.models.generate_content_stream(
model="gemini-3.5-flash",
contents="Hello"
):
print(chunk)
asyncio.run(main())
The request crashes immediately with:
TypeError: StreamReader.readline() got an unexpected keyword argument 'max_line_length'
Root cause
──────────
In google/genai/_api_client.py around line 450, the library calls:
line_bytes = await self.response_stream.content.readline(
max_line_length=READ_BUFFER_SIZE
)
However, aiohttp.StreamReader.readline() does not accept any parameters. Its signature is simply:
async def readline(self) -> bytes:
return await self.readuntil()
The max_line_length keyword argument was introduced in PR #2437, but it is incompatible with the actual aiohttp API.
The line-length limit is already governed by the
limitparameter ofStreamReader,which is set correctly via
read_bufsize=READ_BUFFER_SIZE(4MB) when the aiohttpClientSessionis created:https://github.com/googleapis/python-genai/blob/main/google/genai/_api_client.py#L958
Suggested fix
─────────────
Remove the unsupported max_line_length keyword argument:
line_bytes = await self.response_stream.content.readline()
The existing read_bufsize configuration already prevents LineTooLong errors for large SSE lines.