Gemini API

The fastest path from prompt to production with Gemini, Veo, Nano Banana, and more.

Python

fromgoogleimport genai
client = genai.Client()
response = client.models.generate_content(
 model="gemini-3-flash-preview",
 contents="Explain how AI works in a few words",
)
print(response.text)

JavaScript

import{GoogleGenAI}from"@google/genai";
constai=newGoogleGenAI({});
asyncfunctionmain(){
constresponse=awaitai.models.generateContent({
model:"gemini-2.5-flash",
contents:"Explain how AI works in a few words",
});
console.log(response.text);
}
awaitmain();

Go

packagemain
import(
"context"
"fmt"
"log"
"google.golang.org/genai"
)
funcmain(){
ctx:=context.Background()
client,err:=genai.NewClient(ctx,nil)
iferr!=nil{
log.Fatal(err)
}
result,err:=client.Models.GenerateContent(
ctx,
"gemini-2.5-flash",
genai.Text("Explain how AI works in a few words"),
nil,
)
iferr!=nil{
log.Fatal(err)
}
fmt.Println(result.Text())
}

Java

packagecom.example;
importcom.google.genai.Client;
importcom.google.genai.types.GenerateContentResponse;
publicclass GenerateTextFromTextInput{
publicstaticvoidmain(String[]args){
Clientclient=newClient();
GenerateContentResponseresponse=
client.models.generateContent(
"gemini-2.5-flash",
"Explain how AI works in a few words",
null);
System.out.println(response.text());
}
}

C#

usingSystem.Threading.Tasks;
usingGoogle.GenAI;
usingGoogle.GenAI.Types;
publicclassGenerateContentSimpleText{
publicstaticasyncTaskmain(){
varclient=newClient();
varresponse=awaitclient.Models.GenerateContentAsync(
model:"gemini-2.5-flash",contents:"Explain how AI works in a few words"
);
Console.WriteLine(response.Candidates[0].Content.Parts[0].Text);
}
}

REST

curl"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent"\
-H"x-goog-api-key: $GEMINI_API_KEY"\
-H'Content-Type: application/json'\
-XPOST\
-d'{
 "contents": [
 {
 "parts": [
 {
 "text": "Explain how AI works in a few words"
 }
 ]
 }
 ]
 }'
Start building

Follow our Quickstart guide to get an API key and make your first API call in minutes.


Meet the models

Gemini 3 Pro

Our most intelligent model, the best in the world for multimodal understanding, all built on state-of-the-art reasoning.

Gemini 3 Flash

Frontier-class performance rivaling larger models at a fraction of the cost.

Nano Banana and Nano Banana Pro

State-of-the-art image generation and editing models.

Gemini 2.5 Pro

Our powerful reasoning model, which excels at coding and complex reasonings tasks.

Gemini 2.5 Flash

Our most balanced model, with a 1 million token context window and more.

Gemini 2.5 Flash-Lite

Our fastest and most cost-efficient multimodal model with great performance for high-frequency tasks.

Veo 3.1

Our state-of-the-art video generation model, with native audio.

Gemini 2.5 Pro TTS

Gemini 2.5 model variant with native text-to-speech (TTS) capabilities.

Gemini Robotics-ER 1.5

A vision-language model (VLM) that brings Gemini's agentic capabilities to robotics and enables advanced reasoning in the physical world.

Explore Capabilities

Native Image Generation (Nano Banana)

Generate and edit highly contextual images natively with Gemini 2.5 Flash Image.

Long Context

Input millions of tokens to Gemini models and derive understanding from unstructured images, videos, and documents.

Structured Outputs

Constrain Gemini to respond with JSON, a structured data format suitable for automated processing.

Function Calling

Build agentic workflows by connecting Gemini to external APIs and tools.

Video Generation with Veo 3.1

Create high-quality video content from text or image prompts with our state-of-the-art model.

Voice Agents with Live API

Build real-time voice applications and agents with the Live API.

Tools

Connect Gemini to the world through built-in tools like Google Search, URL Context, Google Maps, Code Execution and Computer Use.

Document Understanding

Process up to 1000 pages of PDF files with full multimodal understanding or other text-based file types.

Thinking

Explore how thinking capabilities improve reasoning for complex tasks and agents.

Resources

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年12月28日 UTC.