Gemini API
借助 Gemini、Veo、Nano Banana 等模型,从提示到生产的最快路径。
Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-3.5-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.5-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.5-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.5-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.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-3.5-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"
}
]
}
]
}'
按照我们的快速入门指南,在几分钟内获取 API 密钥并进行首次 API 调用。
了解模型
查看全部Gemini 3.1 Pro 新
我们最智能的模型,是全球领先的多模态理解模型,全部基于先进的推理技术。
Gemini 3.5 Flash 新
以远低于大型模型的成本,实现与大型模型相媲美的卓越性能。
Gemini 3.1 Flash-Lite 新
高容量、对成本敏感的工作模型,具有 Gemini 3 系列的性能和质量。
Nano Banana 2 和 Nano Banana Pro
先进的图片生成和编辑模型。
Veo 3.1
我们最先进的视频生成模型,具有原生音频。
Gemini Robotics
一种视觉-语言模型 (VLM),可将 Gemini 的智能体功能引入机器人技术,并支持在物理世界中进行高级推理。
探索功能
原生图片生成 (Nano Banana)
使用 Gemini 2.5 Flash Image 原生生成和编辑高度情境化的图片。
长上下文
向 Gemini 模型输入数百万个令牌,并从非结构化图片、视频和文档中提取理解。
结构化输出
限制 Gemini 使用 JSON(一种适合自动处理的结构化数据格式)进行响应。
函数调用
通过将 Gemini 连接到外部 API 和工具来构建智能体工作流。
使用 Veo 3.1 生成视频
使用我们最先进的模型,根据文本或图片提示创建高质量视频内容。
使用 Live API 的语音智能体
使用 Live API 构建实时语音应用和智能体。
工具
通过 Google 搜索、网址上下文、Google 地图、代码执行和计算机使用等内置工具,将 Gemini 连接到世界。
文档理解
处理多达 1000 页的 PDF 文件,并具有完整的多模态理解能力或其他基于文本的文件类型。
思考
了解思考能力如何提高复杂任务和智能体的推理能力。