-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Describe the bug
I notice that if GOOGLE_API_KEY is loaded in os.environ for adk agent, when it is deployed on agent engine, when running it we get error {'code': 498, 'message': 'Project/location and API key are mutually exclusive in the client initializer.'}
To Reproduce
- Create an agent with
GOOGLE_API_KEYloaded
from google.adk.agents import Agent
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
root_agent = Agent( ...)
...
-
deploy the agent following using agent starter pack based on this tutorial https://google.github.io/adk-docs/deploy/agent-engine/
-
Run it and get the error
LOCATION = "us-central1"
import json
import requests
import vertexai
client = vertexai.Client(
location=LOCATION,
)
REASONING_ENGINE_ID = None
if REASONING_ENGINE_ID is None:
try:
with open("../deployment_metadata.json") as f:
metadata = json.load(f)
REASONING_ENGINE_ID = metadata.get("remote_agent_engine_id")
except (FileNotFoundError, json.JSONDecodeError):
pass
print(f"Using REASONING_ENGINE_ID: {REASONING_ENGINE_ID}")
# Get the existing agent engine
remote_agent_engine = client.agent_engines.get(name=REASONING_ENGINE_ID)
async for event in remote_agent_engine.async_stream_query(
message="hi!", user_id="test"
):
print(event)
Expected behavior
As the agent runs correctly when I launch the fastapi server myself (like using adk web), this error clearly is on the agent engine side. And I confirm if I don't load the GOOGLE_API_KEY, everything works fine
Why do I need to load GOOGLE_API_KEY: I have tools that involves gemini api calls. I guess I don't really have to get api key via the environment variable. So this bug is not blocking me on anything. But I think this error is still a bug.
Desktop (please complete the following information):
- OS: linux
- Python version(python -V): 3.10
- ADK version(pip show google-adk): 1.18
Model Information:
- Are you using LiteLLM: No
- Which model is being used: gemini-2.5-flash
