Gemini API 是从提示到生产的最快路径,支持 Gemini、Veo、Nano Banana 等。借助该 API,您可以将这些生成模型集成到应用中,以生成文本和图片、分析多模态输入以及构建对话智能体。
Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-4-argon",
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-4-argon",
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-4-argon",
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-4-argon",
"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-4-argon", 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-4-argon: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 4 Argon 新
我们的旗舰推理模型,具有 100 万 token 的共享上下文窗口,并支持长达 100 万 token 的长解码。
Gemini 3.6 Flash 全新
Google 推出的最新模型,兼顾速度与智能,在智能体和多模态任务中表现出色。
Gemini 3.8 Flash TTS 新
录音室级文字转语音模型,具有富有表现力的演绎、自定义语音设计和语音复刻功能。
Gemini 3.5 Flash-Lite 新
这是一款大体量、成本敏感的模型,针对低延迟、高吞吐量的子智能体任务进行了优化。
Gemini 3.1 Flash-Lite
这款模型专为大体量、成本敏感型应用而设计,兼具 Gemini 3 系列的卓越性能和质量。
Gemini 3 Flash
性能媲美大型模型,成本却低得多。
Nano Banana
先进的图片生成和编辑模型。
Gemini Omni Flash
Google 的前沿视频生成和编辑模型。
Gemini Robotics
这是一款视觉语言模型 (VLM),可将 Gemini 的智能体功能引入机器人技术,并在物理世界中实现高级推理。
探索各项功能
原生图片生成 (Nano Banana)
使用 Gemini 2.5 Flash Image 原生生成和编辑高度契合上下文的图片。
长上下文
向 Gemini 模型输入数百万个 token,并从非结构化图片、视频和文档中获取理解。
结构化输出
限制 Gemini 以 JSON 格式(一种适合自动处理的结构化数据格式)进行回答。
函数调用
通过将 Gemini 连接到外部 API 和工具,构建 Agentic Workflows。
使用 Gemini Omni Flash 生成视频
借助我们前沿的模型,根据文本或图片提示生成高质量视频内容。
使用 Live API 的语音智能体
使用 Live API 构建实时语音应用和智能体。
工具
通过 Google 搜索、网址上下文、Google 地图、代码执行和计算机使用等内置工具,将 Gemini 与世界连接起来。
文档理解
处理多达 1,000 页的 PDF 文件(具有完整的多模态理解能力)或其他基于文本的文件类型。
思考
探索思考能力如何提升复杂任务和智能体的推理能力。