เอกสารนี้จะกล่าวถึงภาพรวมระดับสูงของความแตกต่างระหว่าง Gemini API เวอร์ชัน v1
และ v1beta
- v1: API เวอร์ชันที่เสถียร ฟีเจอร์ในเวอร์ชันเสถียรจะได้รับการรองรับอย่างเต็มที่ตลอดอายุการใช้งานของเวอร์ชันหลัก
หากมีการเปลี่ยนแปลงที่ทำให้เกิดข้อขัดข้อง เราจะสร้าง API เวอร์ชันหลักใหม่และเลิกใช้งานเวอร์ชันที่มีอยู่หลังจากผ่านไประยะเวลาที่เหมาะสม
เราอาจนำการเปลี่ยนแปลงที่ไม่ทำให้เกิดข้อผิดพลาดมาใช้กับ API โดยไม่ต้องเปลี่ยน
เวอร์ชันหลัก Interactions API และฟีเจอร์หลักพร้อมให้บริการโดยทั่วไปใน
v1 - v1beta: เวอร์ชันนี้มีฟีเจอร์และความสามารถในช่วงแรกที่
อยู่ระหว่างการพัฒนา แม้ว่าฟีเจอร์ใน
v1betaอาจมีการเปลี่ยนแปลงเมื่อเราปรับปรุงตามความคิดเห็น แต่ก็ช่วยให้คุณได้ลองใช้ความสามารถใหม่ๆ ก่อนที่จะได้รับการเลื่อนขั้นเป็นเวอร์ชันเสถียร
การรองรับความสามารถและฟีเจอร์
ตารางต่อไปนี้แสดงรายละเอียดความพร้อมใช้งานของความสามารถต่างๆ ใน v1 (GA)
และ v1beta (เบต้า) ความสามารถและเครื่องมือหลักของ API ใช้ได้กับทั้ง
Interactions API และ generateContent เว้นแต่จะระบุไว้เป็นอย่างอื่น
- - รองรับ
กำหนดค่าเวอร์ชัน API ใน SDK
SDK ของ Gemini API จะมีค่าเริ่มต้นเป็น v1beta แต่คุณสามารถระบุเวอร์ชันอย่างชัดเจน
ได้โดยการตั้งค่าเวอร์ชัน API ตามที่แสดงในตัวอย่างโค้ดต่อไปนี้
Python
from google import genai
client = genai.Client(http_options={'api_version': 'v1'})
interaction = client.interactions.create(
model='gemini-3.8-flash',
input="Explain how AI works",
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({
httpOptions: { apiVersion: "v1" },
});
async function main() {
const interaction = await ai.interactions.create({
model: "gemini-3.8-flash",
input: "Explain how AI works",
});
console.log(interaction.output_text);
}
await main();
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.types.HttpOptions;
Client client = Client.builder()
.httpOptions(HttpOptions.builder().apiVersion("v1").build())
.build();
CreateModelInteraction req = CreateModelInteraction.builder()
.model(Model.of("gemini-3.6-flash"))
.input(InteractionsInput.of("Explain how AI works"))
.build();
var interaction = client.interactions.create(CreateInteractionRequestBody.of(req)).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, &genai.ClientConfig{
HTTPOptions: genai.HTTPOptions{
APIVersion: "v1",
},
})
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.6-flash"),
Input: interactions.NewInteractionsInput("Explain how AI works"),
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
REST
curl -X POST "https://generativelanguage.googleapis.com/v1/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",
}'