Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to Connect ADK agents to Vertex AI (API key setup issue)

Hi everyone,

I've been exploring the new Google Agent Development Kit (ADK) and testing the samples available in the ADK Samples GitHub repository . The README files guide users through setting up several conversational agent use cases.

However, all the examples include a step where you're asked to acquire an API key via Google AI Studio , or alternatively, use Vertex AI for setup. Unfortunately, I don’t have permission to get an API key through AI Studio—likely a restriction from my organization.

That said, I’m trying to go the Vertex AI route instead. I noticed there's something called Agent Engine in Vertex AI, but it doesn’t seem to have a UI yet, and I couldn’t find clear documentation on how to proceed via the CLI.

Here is print screen of part of a README.md file from one of the agents:

EBastiani_0-1744816409244.png

My questions for the community:

  1. How are you connecting ADK agents to Vertex AI?

  2. Do you receive an API key from Vertex AI somehow?

  3. Is there a recommended way to authenticate and run the agents using Vertex AI only?

Any guidance or examples would be greatly appreciated!

Thanks in advance!

0 1 750
1 REPLY 1

Hi @EBastiani,

Welcome to the Google Cloud Community!

It looks like you are facing challenges connecting ADK agents due to restrictions on using a Google AI Studio API key. You're exploring Vertex AI as an alternative but need guidance on authenticating and configuring the agents, especially with limited CLI documentation and no Agent Engine UI.

Here are the potential ways that might help with your use case:

  • Set up a Service Account: To set up a Service Account in your Google Cloud Console, you begin by navigating to IAM & Admin, then go to Service Accounts and create a new account with a descriptive name. Next, you grant your account the appropriate permissions, such as 'Vertex AI User' or 'Vertex AI Administrator,' depending on your needs. Be sure to limit permissions to the minimum required for your production environments.
  • Download the JSON key: In your Google Cloud Console, you begin by navigating to IAM & Admin, then go to Service Accounts and locate your service account, go to the "Keys" tab, click "Add Key," select "Create new key," choose JSON as the key type, and save the file securely.
  • Configure AuthenticationYou can set the ‘GOOGLE_APPLICATION_CREDENTIALS’ environment variable to the absolute path of your service account key file, allowing your ADK agent to authenticate using your service account. If you're running the code on a Google VM with the correct IAM permissions, it may automatically use your VM's implicit authentication instead.
  • Testing: Start your ADK agent. If properly configured, it will connect to Vertex AI and utilize the model to generate responses. Monitor the logs in the Cloud Console to identify any authentication or permission-related errors.

Addressing your specific questions:

  1. How are you connecting ADK agents to Vertex AI? You can utilize Google Cloud's service account authentication by either configuring the ‘GOOGLE_APPLICATION_CREDENTIALS’ environment variable for your local development or by employing the service account linked to your compute instance, while ensuring that your assigned service account possesses the necessary IAM permissions.
  2. Do you receive an API key from Vertex AI somehow? Vertex AI does not issue API keys like those provided by Google AI Studio. Instead, authentication is managed through service accounts and IAM roles.
  3. Is there a recommended way to authenticate and run the agents using Vertex AI only? I recommend using a Google Cloud service account with the necessary IAM roles.

Was this helpful? If so, please accept this answer as “Solution”. If you need additional assistance, reply here within 2 business days and I’ll be happy to help.