Environment details
- Programming language: Python
- OS: macOS
- Language runtime version: 3.13
- Package version: google-genai
Steps to reproduce
- Initialize the client for Vertex AI:
client = genai.Client(vertexai=True, project='your-project-id')
- Call the async method:
await client.aio.models.generate_content(model='gemini-2.5-flash', contents='Hello')
- Observe the error:
Failed to send request to https://aiplatform.mtls.googleapis.com/...
Description / Code to Reproduce
When using the google-genai SDK with vertexai=True, calling the asynchronous method await client.aio.models.generate_content fails with a network error pointing to the mTLS endpoint (aiplatform.mtls.googleapis.com). This suggests the async client is defaulting to mTLS and failing because it expects client certificates.
However, using the synchronous method client.models.generate_content with the exact same configuration works successfully in the same environment.
Here is a complete script to reproduce the behavior:
import asyncio
import os
from google import genai
from google.genai import types
async def main():
client = genai.Client(
project=os.environ.get("PROJECT_ID", "your-project-id"),
vertexai=True,
location="us-central1",
http_options=types.HttpOptions(
api_version="v1",
),
)
model_name = "gemini-2.5-flash"
# 1. Try Sync (Works)
try:
print("Trying sync call...")
response = client.models.generate_content(
model=model_name,
contents="Hello",
)
print("Sync Success!")
except Exception as e:
print(f"Sync Error: {e}")
# 2. Try Async (Fails)
try:
print("\nTrying async call...")
response = await client.aio.models.generate_content(
model=model_name,
contents="Hello",
)
print("Async Success!")
except Exception as e:
print(f"Async Error: {e}")
if __name__ == "__main__":
asyncio.run(main())
Environment details
Steps to reproduce
client = genai.Client(vertexai=True, project='your-project-id')await client.aio.models.generate_content(model='gemini-2.5-flash', contents='Hello')Failed to send request to https://aiplatform.mtls.googleapis.com/...Description / Code to Reproduce
When using the
google-genaiSDK withvertexai=True, calling the asynchronous methodawait client.aio.models.generate_contentfails with a network error pointing to the mTLS endpoint (aiplatform.mtls.googleapis.com). This suggests the async client is defaulting to mTLS and failing because it expects client certificates.However, using the synchronous method
client.models.generate_contentwith the exact same configuration works successfully in the same environment.Here is a complete script to reproduce the behavior: