คำอธิบายเวอร์ชัน API

เอกสารนี้ให้ภาพรวมระดับสูงเกี่ยวกับความแตกต่างระหว่าง Gemini API เวอร์ชัน v1 กับ v1beta

  • v1: API เวอร์ชันเสถียร ระบบจะรองรับฟีเจอร์ในเวอร์ชันเสถียรอย่างเต็มที่ตลอดอายุการใช้งานของเวอร์ชันหลัก หากมีการเปลี่ยนแปลงที่ทำให้เกิดข้อขัดข้อง ระบบจะสร้าง API เวอร์ชันหลักใหม่และเลิกใช้งานเวอร์ชันที่มีอยู่หลังจากผ่านไประยะเวลาหนึ่ง นอกจากนี้ เราอาจนำการเปลี่ยนแปลงที่ไม่ทำให้เกิดข้อขัดข้องมาใช้กับ API โดยไม่เปลี่ยนเวอร์ชันหลัก Interactions API และฟีเจอร์หลักพร้อมให้บริการโดยทั่วไปใน v1
  • v1beta: เวอร์ชันนี้มีฟีเจอร์และความสามารถในช่วงแรกที่อยู่ระหว่างการพัฒนา แม้ว่าฟีเจอร์ใน v1beta อาจมีการเปลี่ยนแปลงเมื่อเราปรับปรุงฟีเจอร์ตามความคิดเห็น แต่เวอร์ชันนี้จะช่วยให้คุณได้ลองใช้ความสามารถใหม่ๆ ก่อนที่จะโปรโมตเป็นเวอร์ชันเสถียร

การรองรับความสามารถและฟีเจอร์

ตารางต่อไปนี้แสดงรายละเอียดความพร้อมใช้งานของความสามารถใน v1 (GA) และ v1beta (เบต้า) ความสามารถและเครื่องมือหลักของ API ใช้ได้กับทั้ง Interactions API และ generateContent เว้นแต่จะระบุไว้เป็นอย่างอื่น

ฟีเจอร์ v1 v1beta
ความสามารถหลักของ API
Interactions API
การเรียกฟังก์ชัน
เอาต์พุตที่มีโครงสร้าง
การคิด / การให้เหตุผล
คำแนะนำของระบบ
เอาต์พุตเสียง (การกำหนดค่าเสียงพูด)
ระดับบริการ (ลำดับความสำคัญ / ยืดหยุ่น)
เครื่องมือ
เครื่องมือการรันโค้ด
การอ้างอิงจาก Google Search
การอ้างอิงจาก Google Maps
เครื่องมือบริบท URL
เครื่องมือค้นหาไฟล์
เครื่องมือการใช้คอมพิวเตอร์
เครื่องมือเซิร์ฟเวอร์ MCP
API แบบเรียลไทม์
Live API (WebSockets)
Live Music API
โทเค็นชั่วคราว (Live API)
API ของแพลตฟอร์ม
Models API
เส้นทางบริการไฟล์
เส้นทางที่เก็บข้อมูลการค้นหาไฟล์
Agents API
Webhooks API
การแคชบริบท
  • - รองรับ

กำหนดค่าเวอร์ชัน API ใน SDK

Gemini API SDK จะใช้ v1beta เป็นค่าเริ่มต้น แต่คุณสามารถระบุเวอร์ชันอย่างชัดเจนได้โดยตั้งค่าเวอร์ชัน API ตามที่แสดงในตัวอย่างโค้ดต่อไปนี้

Python

from google import genai

client = genai.Client(http_options={'api_version': 'v1'})

interaction = client.interactions.create(
    model='gemini-3.7-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.7-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(""));

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.7-flash",
    "input": "Explain how AI works",
  }'