Get started with Gemini Enterprise Agent Platform (original) (raw)

This quickstart shows you how to install the Google Gen AI SDK for your language of choice and then make your first API request.

Choose your authentication method

You can authenticate to Gemini Enterprise Agent Platform by using Application Default Credentials (ADC) or by using an API key. ADC is the recommended method.

Before you begin

Set up ADC by using a setup script or complete the steps manually.

MacOS/Linux

bash <(curl -sSL
https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.sh)

Windows

powershell -c "iex (irm https://storage.googleapis.com/cloud-samples-data/adc/setup_adc.ps1)"

Console manual steps

If you have already configured ADC, skip to the next step.

To configure ADC, do the following:

Configure your project

Select a project, enable billing, enable the Agent Platform API, and install the gcloud CLI:

Create local authentication credentials

If you're using a local shell, then create local authentication credentials for your user account:

gcloud auth application-default login

You don't need to do this if you're using Cloud Shell.

If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.

Set up required roles

If you're using a standard API key or ADC, your project also needs to be granted the appropriate Identity and Access Management permissions for Gemini Enterprise Agent Platform. If you're using an express mode API key, you can skip to the next step.

To get the permissions that you need to use Gemini Enterprise Agent Platform, ask your administrator to grant you theAgent Platform User (roles/aiplatform.user) IAM role on your project. For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Install the SDK and set up your environment

On your local machine, click one of the following tabs to install the SDK for your programming language.

Python

Install and update the Google Gen AI SDK for Python by running this command.

pip install --upgrade google-genai

Set environment variables:

Replace the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_LOCATION values

with appropriate values for your project.

export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT_ID export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_ENTERPRISE=True

Go

Install and update the Google Gen AI SDK for Go by running this command.

go get google.golang.org/genai

Set environment variables:

Replace the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_LOCATION values

with appropriate values for your project.

export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT_ID export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_ENTERPRISE=True

Node.js

Install and update the Google Gen AI SDK for Node.js by running this command.

npm install @google/genai

Set environment variables:

Replace the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_LOCATION values

with appropriate values for your project.

export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT_ID export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_ENTERPRISE=True

Java

Install and update the Google Gen AI SDK for Java by running this command.

Maven

Add the following to your pom.xml:

com.google.genai google-genai 0.7.0

Set environment variables:

Replace the GOOGLE_CLOUD_PROJECT_ID and GOOGLE_CLOUD_LOCATION values

with appropriate values for your project.

export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT_ID export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_ENTERPRISE=True

REST

Set environment variables:

GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT_ID GOOGLE_CLOUD_LOCATION="global" API_ENDPOINT="https://aiplatform.googleapis.com" MODEL_ID="gemini-2.5-flash" GENERATE_CONTENT_API="generateContent"

Replace GOOGLE_CLOUD_PROJECT_ID with your Google Cloud project ID.

Make your first request

Use thegenerateContentmethod to send a request to the Gemini API in Gemini Enterprise Agent Platform.

The following examples show how to make a request using one of the SDKs or REST. To run an SDK example, copy the code to a file (for example,request.py) and run the file from your terminal (for example,python request.py).

Python

Go

Node.js

Java

C#

REST

To send this prompt request, run the curl command from the command line or include the REST call in your application.

curl
-X POST
-H "Content-Type: application/json"
-H "Authorization: Bearer $(gcloud auth print-access-token)"
"${API_ENDPOINT}/v1/projects/${GOOGLE_CLOUD_PROJECT}/locations/${GOOGLE_CLOUD_LOCATION}/publishers/google/models/${MODEL_ID}:${GENERATE_CONTENT_API}" -d
$'{ "contents": { "role": "user", "parts": { "text": "Explain how AI works in a few words" } } }'

The model returns a response. Note that the response is generated in sections with each section separately evaluated for safety.

Generate images

Gemini can generate and process images conversationally. You can prompt Gemini with text, images, or a combination of both to achieve various image-related tasks, such as image generation and editing. The following code demonstrates how to generate an image based on a descriptive prompt:

You must include responseModalities: ["TEXT", "IMAGE"] in your configuration. Image-only output is not supported with these models.

Understand images

Gemini can understand images as well. The following code uses the image generated in the previous section and uses a different model to infer information about the image:

Use code execution

The Gemini API in Gemini Enterprise Agent Platform code execution feature enables the model to generate and run Python code and learn iteratively from the results until it arrives at a final output. Gemini Enterprise Agent Platform provides code execution as a tool, similar to function calling. You can use this code execution capability to build applications that benefit from code-based reasoning and that produce text output. For example:

For more examples of code execution, check out the code execution documentation.

What's next

Now that you made your first API request, you might want to explore the following guides that show how to set up more advanced Gemini Enterprise Agent Platform features for production code:

Quickstart

Develop with the SDK

Learn how to accelerate development by connecting your AI tools to the Developer Knowledge MCP server.

Quickstart

Vibe code an agent with ADK

Use the Agent Development Kit (ADK) to build, test, and deploy a prototype agent to a Google Cloud runtime.

Guide

Get started with Gemini 3

Learn about Gemini 3, our most intelligent model family to date, built on a foundation of state-of-the-art reasoning.

Overview

Explore Google models

Explore the latest Google models supported in Agent Platform, including Gemini, Veo, and Gemma.