借助 Gemini API,您可以快速将提示词转化为实际应用,并利用 Gemini、Veo、Nano Banana 等工具实现更多功能。借助该 SDK,您可以将这些生成式模型集成到应用中,以生成文本和图片、分析多模态输入内容,以及构建对话式代理。
Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.8-flash",
contents="Explain how AI works in a few words",
)
print(response.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
async function main() {
const response = await ai.models.generateContent({
model: "gemini-3.8-flash",
contents: "Explain how AI works in a few words",
});
console.log(response.text);
}
await main();
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
result, err := client.Models.GenerateContent(
ctx,
"gemini-3.8-flash",
genai.Text("Explain how AI works in a few words"),
nil,
)
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Text())
}
Java
package com.example;
import com.google.genai.Client;
import com.google.genai.types.GenerateContentResponse;
public class GenerateTextFromTextInput {
public static void main(String[] args) {
Client client = new Client();
GenerateContentResponse response =
client.models.generateContent(
"gemini-3.8-flash",
"Explain how AI works in a few words",
null);
System.out.println(response.text());
}
}
C#
using System.Threading.Tasks;
using Google.GenAI;
using Google.GenAI.Types;
public class GenerateContentSimpleText {
public static async Task main() {
var client = new Client();
var response = await client.Models.GenerateContentAsync(
model: "gemini-3.8-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-3.8-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"contents": [
{
"parts": [
{
"text": "Explain how AI works in a few words"
}
]
}
]
}'
认识这些模型
查看全部Gemini 3.1 Pro 新
Google 最智能的模型,也是全球领先的多模态理解能力模型,建立在前沿推理技术基础上。
Gemini 3.6 Flash 新
Google 推出的最新模型,在速度和智能性之间实现了平衡,可在智能体和多模态任务中提供出色的性能。
Gemini 3.5 Flash
以远低于大型模型的成本,实现可与 Frontier 级模型相媲美的性能。
Gemini 3.5 Flash-Lite 新
经济高效的模型,专为大体量、成本敏感的子智能体任务而设计,并针对低延迟高吞吐量进行了优化。
Gemini 3.1 Flash-Lite
这款模型具有 Gemini 3 系列的性能和质量,可处理大体量的成本敏感型流量。
Gemini 3 Flash
以远低于大型模型的成本,实现可与 Frontier 级模型相媲美的性能。
Nano Banana 2 和 Nano Banana Pro
前沿的图片生成和编辑模型。
Veo 3.1
我们前沿的视频生成模型,支持原生音频。
Gemini Robotics
一种视觉-语言模型 (VLM),可将 Gemini 的智能体功能引入机器人技术,并支持在物理世界中进行高级推理。
探索功能
原生图片生成 (Nano Banana)
使用 Gemini 2.5 Flash Image 原生生成和编辑高度情境化的图片。
长上下文
向 Gemini 模型输入数百万个 token,并从非结构化的图片、视频和文档中获取理解。
结构化输出
限制 Gemini 以 JSON(一种适合自动处理的结构化数据格式)进行回答。
函数调用
通过将 Gemini 连接到外部 API 和工具来构建智能体工作流。
使用 Veo 3.1 生成视频
借助我们前沿的模型,根据文本或图片提示创作高品质视频内容。
使用 Live API 的语音智能体
使用 Live API 构建实时语音应用和代理。
工具
通过 Google 搜索、网址上下文、Google 地图、代码执行和计算机使用等内置工具,将 Gemini 与世界相连。
文档理解
处理最多 1,000 页的 PDF 文件(支持完整的多模态理解能力)或其他基于文本的文件类型。
思考
了解思维能力如何改进复杂任务和代理的推理能力。