Gemini API เป็นเส้นทางที่เร็วที่สุดจากพรอมต์ไปสู่การใช้งานจริงด้วย Gemini, Veo, Nano Banana และอื่นๆ โดยจะช่วยให้คุณผสานรวมโมเดล Generative เหล่านี้เข้ากับแอปพลิเคชันเพื่อสร้างข้อความและรูปภาพ วิเคราะห์อินพุตแบบหลายรูปแบบ และสร้าง Agent ที่สามารถสนทนาได้
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
input="Explain how AI works in a few words"
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
input: "Explain how AI works in a few words",
});
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(InteractionsInput.of("Explain how AI works in a few words"))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Explain how AI works in a few words"),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.8-flash",
"input": "Explain how AI works in a few words"
}'
พบกับโมเดล
ดูทั้งหมดGemini 4 Argon ใหม่
โมเดลการให้เหตุผลหลักของเราที่มีหน้าต่างบริบทขนาด 1 ล้านโทเค็นที่ใช้ร่วมกันและการถอดรหัสแบบยาวสูงสุด 1 ล้านโทเค็น
Gemini 3.8 Flash ใหม่
โมเดล Flash ที่ชาญฉลาดที่สุดของเรา ซึ่งได้รับการออกแบบมาเพื่อการพัฒนาซอฟต์แวร์ในระยะยาว Agent ที่ทำงานได้ด้วยตัวเอง และเวิร์กโฟลว์ที่ซับซ้อนขององค์กร
Gemini 3.8 Flash TTS ใหม่
โมเดลการอ่านออกเสียงข้อความระดับสตูดิโอที่มีการแสดงออกที่ชัดเจน การออกแบบเสียงที่กำหนดเอง และการจำลองเสียง
Gemini 3.5 Flash-Lite
โมเดลที่มีปริมาณงานสูงและคำนึงถึงต้นทุน ซึ่งได้รับการเพิ่มประสิทธิภาพสำหรับงานของ Subagent ที่มีเวลาในการตอบสนองต่ำและการส่งข้อความปริมาณมาก
Nano Banana
โมเดลการสร้างและแก้ไขรูปภาพที่ล้ำสมัย
Gemini Omni Flash
โมเดลการสร้างและแก้ไขวิดีโอที่ล้ำสมัยของเรา
Gemini 3.5 Transcribe ใหม่
โมเดลการแปลงเสียงพูดเป็นข้อความที่มีเวลาในการตอบสนองต่ำ พร้อมการตรวจหาภาษาตามคำพูด การแยกผู้พูด และการประทับเวลาของคำ
Gemini Robotics
โมเดลวิสัยทัศน์และภาษา (VLM) ที่นำความสามารถด้าน Agentic AI ของ Gemini มาใช้กับหุ่นยนต์และช่วยให้สามารถให้เหตุผลขั้นสูงในโลกทางกายภาพได้
สำรวจความสามารถ
การสร้างรูปภาพ
สร้างและแก้ไขรูปภาพที่มีบริบทสูงได้โดยตรงด้วย Nano Banana
บริบทแบบยาว
ป้อนข้อมูลหลายล้านโทเค็นลงในโมเดล Gemini และดึงข้อมูลเชิงลึกจากรูปภาพ วิดีโอ และเอกสารที่ไม่มีโครงสร้าง
เอาต์พุตที่มีโครงสร้าง
จำกัดให้ Gemini ตอบกลับด้วย JSON ซึ่งเป็นรูปแบบข้อมูลที่มีโครงสร้างที่เหมาะสำหรับการประมวลผลอัตโนมัติ
การเรียกใช้ฟังก์ชัน
สร้างเวิร์กโฟลว์ของ Agent โดยการเชื่อมต่อ Gemini กับ API และเครื่องมือภายนอก
การสร้างวิดีโอด้วย Veo 3.1
สร้างเนื้อหาวิดีโอคุณภาพสูงจากพรอมต์ข้อความหรือรูปภาพด้วยโมเดลที่ล้ำสมัยของเรา
Agent ที่ใช้เสียงพูดพร้อม Live API
สร้างแอปพลิเคชันและ Agent ที่ใช้เสียงพูดแบบเรียลไทม์ด้วย Live API
เครื่องมือ
เชื่อมต่อ Gemini กับโลกภายนอกผ่านเครื่องมือในตัว เช่น Google Search, บริบท URL, Google Maps, การดำเนินการโค้ด และการใช้คอมพิวเตอร์
การทำความเข้าใจเอกสาร
ประมวลผลไฟล์ PDF ได้สูงสุด 1,000 หน้าด้วยความเข้าใจข้อมูลหลายรูปแบบอย่างเต็มรูปแบบหรือประเภทไฟล์อื่นๆ ที่อิงตามข้อความ
กำลังคิด
สำรวจวิธีที่ความสามารถในการคิดช่วยปรับปรุงการให้เหตุผลสำหรับงานและ Agent ที่ซับซ้อน
สร้าง Agent
Agent ที่ได้รับการจัดการจะให้พื้นที่ทำงานแก่ Gemini เพื่อวางแผนและทำงานให้เสร็จด้วยตัวเอง Gemini สามารถเขียนและเรียกใช้โค้ด ค้นหาเว็บ และสร้างไฟล์ในสภาพแวดล้อมแซนด์บ็อกซ์ที่โฮสต์ไว้ได้ในคำขอเดียว เริ่มต้นด้วย Agent Antigravity ที่สร้างไว้ล่วงหน้า หรือปรับแต่งด้วยคำแนะนำและเครื่องมือของคุณเอง
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-09-2026",
input=(
"Research the top 5 sustainable fashion brands, "
"compare their materials and pricing tiers, and "
"build an interactive dashboard in analysis.html."
),
environment="remote"
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
agent: "antigravity-preview-09-2026",
input:
"Research the top 5 sustainable fashion brands, " +
"compare their materials and pricing tiers, and " +
"build an interactive dashboard in analysis.html.",
environment: "remote",
});
console.log(interaction.output_text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateAgentInteraction params =
CreateAgentInteraction.builder()
.agent(AgentOption.of("antigravity-preview-09-2026"))
.input(
InteractionsInput.of(
"Research the top 5 sustainable fashion brands, "
+ "compare their materials and pricing tiers, and "
+ "build an interactive dashboard in analysis.html."))
.environment(CreateAgentInteractionEnvironment.of("remote"))
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params))
.interaction()
.get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateAgentInteraction{
Agent: interactions.AgentOption("antigravity-preview-09-2026"),
Input: interactions.NewInteractionsInput(
"Research the top 5 sustainable fashion brands, " +
"compare their materials and pricing tiers, and " +
"build an interactive dashboard in analysis.html.",
),
Environment: genai.Ptr(interactions.NewCreateAgentInteractionEnvironment("remote")),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
REST
curl -X POST \
"https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"agent": "antigravity-preview-09-2026",
"input": "Research the top 5 sustainable fashion brands, compare their materials and pricing tiers, and build an interactive dashboard in analysis.html.",
"environment": "remote"
}'
Interactions API
Interactions API ได้กลายเป็นอินเทอร์เฟซเริ่มต้นของเราตั้งแต่เดือนมิถุนายน 2026 และเป็นวิธีที่ดีที่สุดในการสร้างด้วยโมเดล Gemini และ Agent ในอนาคต หากเริ่มต้นโปรเจ็กต์ใหม่ คุณควรใช้ Interactions API แม้ว่าเราจะยังคงให้การสนับสนุนอยู่ แต่ตอนนี้ generateContent API ถือเป็น API รุ่นเก่า