This quickstart shows you how to install the Google Gen AI SDK for your language of choice and then make your first API request. It covers the following topics: Choose your authentication method: Configure application default credentials if you
haven't yet. The following diagram summarizes the overall workflow: On your local machine, click one of the following tabs to install the SDK for your programming language. Install and update the Gen AI SDK for Python by running this command. Set environment variables: Install and update the Gen AI SDK for Go by running this command. Set environment variables: Install and update the Gen AI SDK for Node.js by running this command. Set environment variables: To install the Gen AI SDK for Java, add the following dependency to your Maven Set environment variables: Set environment variables: Now that you made your first API request, you might want to explore the
following guides that show how to set up more advanced Vertex AI
features for production code:
generateContent
method to send a text prompt and receive a response.
Authentication Method
Description
Use Case
API key
A simple encrypted string that you can use to call the Gemini API in Vertex AI.
Best for quick prototyping and development when you don't need to access Google Cloud resources.
Application Default Credentials (ADC)
A strategy that finds credentials automatically based on the application environment, without needing to modify application code.
Recommended for most production applications, especially those running on Google Cloud, as it provides more robust and secure authentication.
Before you begin
Concepts
Prerequisites
Install the SDK and set up your environment
Gen AI SDK for Python
pip install --upgrade google-genai
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Gen AI SDK for Go
go get google.golang.org/genai
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Gen AI SDK for Node.js
npm install @google/genai
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
Gen AI SDK for Java
pom.xml
file:<dependencies>
<dependency>
<groupId>com.google.genai</groupId>
<artifactId>google-genai</artifactId>
<version>0.7.0</version>
</dependency>
</dependencies>
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
# with appropriate values for your project.
export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
export GOOGLE_CLOUD_LOCATION=global
export GOOGLE_GENAI_USE_VERTEXAI=True
REST
GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
GOOGLE_CLOUD_LOCATION=global
API_ENDPOINT=YOUR_API_ENDPOINT
MODEL_ID="gemini-2.5-flash"
GENERATE_CONTENT_API="generateContent"
What's next
Gemini API in Vertex AI quickstart
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-18 UTC.