มีอะไรใหม่ใน Gemini 3.5 Flash

โมเดลล่าสุด โมเดลอื่นๆ

Gemini 3.5 Flash (gemini-3.5-flash) เป็นโมเดล Flash รุ่นก่อนหน้าที่เลิกใช้งานแล้วในซีรีส์ Gemini 3 ระบบจะกำหนดเส้นทางคำขอไปยัง gemini-3.5-flash เป็น Gemini 3.6 Flash โดยอัตโนมัติ ดูโมเดล Flash ล่าสุดได้ที่ Gemini 3.8 Flash

คู่มือนี้จะเก็บไว้เพื่อใช้อ้างอิงในอดีตและบันทึกการเปลี่ยนแปลง API พื้นฐานของ Gemini 3.x รวมถึงคำแนะนำพารามิเตอร์

ภาพรวมโมเดล

โมเดล รหัสโมเดล สถานะ
Gemini 3.5 Flash gemini-3.5-flash เลิกใช้งาน (กำหนดเส้นทางไปยัง gemini-3.6-flash โดยอัตโนมัติ)

Gemini 3.5 Flash รองรับหน้าต่างบริบทขนาด 1 ล้านโทเค็น, โทเค็นเอาต์พุตสูงสุด 65,000 รายการ, การคิด และชุดเครื่องมือและฟีเจอร์แพลตฟอร์มชุดเดียวกับ Gemini 3 Flash, ซึ่งรวมถึง การใช้คอมพิวเตอร์ (เวอร์ชันตัวอย่าง)

ดูข้อมูลจำเพาะทั้งหมดได้ที่ภาพรวมโมเดล

คู่มือเริ่มใช้งานฉบับย่อ

ตัวอย่างทั้งหมดในคู่มือนี้ใช้ Interactions API นอกจากนี้ยังรองรับ GenerateContent API ด้วย โดยใช้ตัวเลือกการกำหนดค่าและคำแนะนำเดียวกัน

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.5-flash",
    input="Explain how parallel agentic execution works in three sentences."
)
print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const interaction = await client.interactions.create({
    model: "gemini-3.5-flash",
    input: "Explain how parallel agentic execution works in three sentences.",
  });
  console.log(interaction.output_text);
}

main();

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.5-flash"))
        .input(
            InteractionsInput.of(
                "Explain how parallel agentic execution works in three sentences."))
        .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.5-flash"),
            Input: interactions.NewInteractionsInput("Explain how parallel agentic execution works in three sentences."),
        }),
    })
    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.5-flash",
    "input": "Explain how parallel agentic execution works in three sentences."
  }'

มีอะไรใหม่

  • ประสิทธิภาพที่ยั่งยืน: เพิ่มประสิทธิภาพสำหรับงานแบบ Agentic และงานเขียนโค้ดในวงกว้าง
  • การดำเนินการแบบ Agentic: การติดตั้งใช้งาน Agent ย่อย การแก้ปัญหา และการวนซ้ำแบบ Agentic อย่างรวดเร็วในวงกว้าง
  • การเขียนโค้ด: รอบการเขียนโค้ดแบบวนซ้ำ การสำรวจอย่างรวดเร็ว และการสร้างต้นแบบเพื่อทดสอบเส้นทางอื่นและสำรวจโซลูชันแบบไดนามิก
  • ระยะยาว: เวิร์กโฟลว์แบบหลายขั้นตอนและการใช้เครื่องมือในวงกว้าง
  • การเก็บรักษาองค์ความรู้: โมเดลจะเก็บรักษาการให้เหตุผลระดับกลางในการสนทนาแบบหลายรอบโดยอัตโนมัติ ไม่ต้องเปลี่ยนแปลง API
  • ระดับความพยายามเริ่มต้นใหม่: ระดับความพยายามในการคิดเริ่มต้นเปลี่ยนจาก high เป็น medium ดูรายละเอียดได้ที่ ระดับความพยายามเริ่มต้นใหม่
  • การคิดระดับ low ที่ปรับปรุงแล้ว: low ได้รับการปรับปรุงอย่างมากสำหรับงานเขียนโค้ด และงานแบบ Agentic ที่ต้องใช้ขั้นตอนน้อยลง โดยให้คุณภาพสูงด้วยเวลาในการตอบสนองและค่าใช้จ่ายที่ต่ำลง

การเลือกโมเดล Flash ที่เหมาะสม

เนื่องจาก gemini-3.5-flash เลิกใช้งานแล้วและระบบจะกำหนดเส้นทางไปยัง gemini-3.6-flash โดยอัตโนมัติ เราจึงขอแนะนำให้ย้ายข้อมูลไปยังโมเดลที่ใช้งานอยู่ต่อไปนี้

  • Gemini 3.8 Flash: โมเดล Flash ล่าสุดและฉลาดที่สุดของเราสำหรับเวิร์กโฟลว์การเขียนโค้ดและเวิร์กโฟลว์แบบ Agentic ที่ซับซ้อน ดูคู่มือ Gemini 3.8 Flash
  • Gemini 3.6 Flash: โมเดลที่ใช้แทน gemini-3.5-flash ได้โดยตรง โดยใช้โทเค็นน้อยลงและมีราคาเอาต์พุตต่ำกว่า ดูคู่มือ Gemini 3.6 Flash และ 3.5 Flash-Lite
  • Gemini 3.5 Flash-Lite / Gemini 3.1 Flash-Lite: สำหรับงานปริมาณมากที่มีต้นทุนต่ำซึ่งไม่จำเป็นต้องใช้การให้เหตุผลแบบ Flash เต็มรูปแบบ ให้ใช้ Gemini 3.5 Flash-Lite หรือ Gemini 3.1 Flash-Lite

การเปลี่ยนแปลงลักษณะการทำงาน

ระดับความพยายามเริ่มต้นใหม่: medium

ระดับการประมวลผลความคิดเริ่มต้นตอนนี้คือ medium ซึ่งเปลี่ยนจาก high ใน Gemini 3 Flash เวอร์ชันตัวอย่าง medium ให้ผลลัพธ์ที่ดีมากสำหรับงานที่หลากหลาย ขณะเดียวกันก็รวดเร็วและประหยัดค่าใช้จ่ายมากขึ้น สำหรับปัญหาที่ซับซ้อน high จะกระตุ้นให้โมเดลคิดอย่างลึกซึ้งมากขึ้น

ระดับความพยายาม กรณีที่ควรใช้
minimal เพิ่มประสิทธิภาพความเร็วในการตอบสนอง กรณีการใช้งานคล้ายแชท คำตอบข้อเท็จจริงอย่างรวดเร็ว การเรียกใช้เครื่องมือที่ง่ายขึ้น
low งานเขียนโค้ดและงานแบบ Agentic ที่ต้องใช้เวลาในการตอบสนองต่ำกว่าและขั้นตอนน้อยลง นอกจากนี้ยังเหมาะกับงานวิเคราะห์และงานเขียนที่ต้องใช้การคิด
medium (ค่าเริ่มต้น) คุณภาพดีที่สุดสำหรับงานส่วนใหญ่ แนะนำสำหรับกรณีการใช้งานเขียนโค้ดและแบบ Agentic ที่ซับซ้อน
high เพิ่มความสามารถของโมเดลในการคิดและใช้เครื่องมือให้สูงสุด เหมาะที่สุดสำหรับการให้เหตุผลที่ซับซ้อน คณิตศาสตร์ที่ยาก และงานเขียนโค้ดหรืองานแบบ Agent ที่ยากที่สุด อนุญาตให้คิดและเรียกใช้ฟังก์ชันได้นานขึ้น

หากต้องการลบล้างค่าเริ่มต้น ให้ตั้งค่า thinking_level ในการกำหนดค่า

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.5-flash",
    input="Prove that the square root of 2 is irrational.",
    generation_config={"thinking_level": "high"},
)
print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const interaction = await client.interactions.create({
    model: "gemini-3.5-flash",
    input: "Prove that the square root of 2 is irrational.",
    generationConfig: { thinkingLevel: "high" },
  });
  console.log(interaction.output_text);
}

main();

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GenerationConfig;
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.interactions.ThinkingLevel;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.5-flash"))
        .input(InteractionsInput.of("Prove that the square root of 2 is irrational."))
        .generationConfig(GenerationConfig.builder().thinkingLevel(ThinkingLevel.HIGH).build())
        .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.5-flash"),
            Input: interactions.NewInteractionsInput("Prove that the square root of 2 is irrational."),
            GenerationConfig: &interactions.GenerationConfig{
                ThinkingLevel: interactions.ThinkingLevelHigh.ToPointer(),
            },
        }),
    })
    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.5-flash",
    "input": "Prove that the square root of 2 is irrational.",
    "generation_config": {"thinking_level": "high"}
  }'

ตารางต่อไปนี้แสดงระดับการคิดที่รองรับต่อโมเดล

ระดับการคิด Gemini 3.5 Flash Gemini 3.1 Pro Gemini 3.1 Flash-Lite Gemini 3 Flash คำอธิบาย
minimal รองรับ ไม่รองรับ รองรับ (ค่าเริ่มต้น) รองรับ ตรงกับการตั้งค่า "ไม่คิด" สำหรับการค้นหาส่วนใหญ่ โปรดทราบว่า minimal ไม่รับประกันว่าจะปิดการคิด โมเดลอาจให้เหตุผลน้อยมากสำหรับงานที่ซับซ้อน
low รองรับ รองรับ รองรับ รองรับ ลดเวลาในการตอบสนองและค่าใช้จ่ายให้เหลือน้อยที่สุด
medium รองรับ (ค่าเริ่มต้น) รองรับ รองรับ รองรับ การคิดที่สมดุลสำหรับงานส่วนใหญ่
high รองรับ (ไดนามิก) รองรับ (ค่าเริ่มต้น, ไดนามิก) รองรับ (ไดนามิก) รองรับ (ค่าเริ่มต้น, ไดนามิก) เพิ่มความลึกของการให้เหตุผลให้สูงสุด

การเก็บรักษาองค์ความรู้

โมเดลจะเก็บรักษาการให้เหตุผลระดับกลางในการสนทนาแบบหลายรอบโดยอัตโนมัติ เมื่อมีอยู่ในประวัติการสนทนา บริบทการให้เหตุผลจะถูกส่งต่อ ซึ่งช่วยปรับปรุงประสิทธิภาพสำหรับงานที่ซับซ้อนแบบหลายขั้นตอน เช่น การแก้ไขข้อบกพร่องแบบวนซ้ำและการเปลี่ยนโครงสร้างภายในโค้ด ไม่ต้องเปลี่ยนแปลง API โดยมีรายละเอียดดังนี้

  • Interactions API: ระบบจะเก็บรักษาองค์ความรู้โดยอัตโนมัติอยู่แล้ว ไม่มีการเปลี่ยนแปลงลักษณะการทำงาน
  • GenerateContent API: โมเดลจะใช้ บริบทการให้เหตุผลจากการสนทนาก่อนหน้านี้ทั้งหมดเมื่อมีลายเซ็นองค์ความรู้ ในประวัติการสนทนา โดยเริ่มจาก Gemini 3.5 Flash หากต้องการเปิดใช้ฟีเจอร์นี้ ให้ส่งประวัติการสนทนาแบบเต็ม ที่ไม่ได้แก้ไข (รวมถึง ลายเซ็นองค์ความรู้) ใน contents SDK จะจัดการเรื่องนี้โดยอัตโนมัติ

การอัปเดตพารามิเตอร์และแนวทางปฏิบัติแนะนำใน Gemini 3.x

ข้อความต่อไปนี้มีผลกับโมเดล Gemini 3.x ทั้งหมด ซึ่งรวมถึง Gemini 3.5 Flash

  • temperature, top_p, top_k: เราขอแนะนำอย่างยิ่งว่าอย่าเปลี่ยนค่าเริ่มต้น ความสามารถในการให้เหตุผลของ Gemini 3 ได้รับการเพิ่มประสิทธิภาพสำหรับการตั้งค่าเริ่มต้น
  • ใช้ thinking_level แทน thinking_budget
  • การจับคู่การตอบกลับการเรียกใช้ฟังก์ชัน: id, name และจำนวนการตอบกลับ ต้องตรงกับการเรียกใช้ก่อนหน้า
  • การตอบกลับฟังก์ชันแบบมัลติโมดัล: รวมเนื้อหาแบบมัลติโมดัลไว้ในการตอบกลับฟังก์ชัน ไม่ใช่ภายนอก
  • คำแนะนำแบบอินไลน์ในการตอบกลับฟังก์ชัน: เพิ่มต่อท้ายข้อความการตอบกลับฟังก์ชัน ไม่ใช่เป็นส่วนแยกต่างหาก
  • ลดการเรียกใช้เครื่องมือที่ไม่จำเป็น: ใช้ระดับการคิดที่ต่ำลงหรือทดลองใช้ คำแนะนำระบบเพื่อลดการเรียกใช้เครื่องมือในเวิร์กโฟลว์แบบ Agentic

ดูวิธีอัปเดตโค้ดได้ในส่วนด้านล่าง

พารามิเตอร์การสุ่มตัวอย่าง (ไม่แนะนำอีกต่อไป)

เราไม่แนะนำให้ใช้ temperature, top_p และ top_k สำหรับโมเดล Gemini 3.x ทั้งหมดอีกต่อไป ความสามารถในการให้เหตุผลของ Gemini 3 ได้รับการเพิ่มประสิทธิภาพสำหรับการตั้งค่าเริ่มต้น นำพารามิเตอร์เหล่านี้ออกจากคำขอทั้งหมด

# ⚠️ Remove these parameters (not recommended)
generation_config = {
    "temperature": 0.7,
    "top_p": 0.9,
    "top_k": 40,
}

เราขอแนะนำให้กำหนดคำแนะนำระบบที่มีกฎที่ชัดเจนสำหรับกรณีการใช้งานเฉพาะของคุณเพื่อให้ได้ผลลัพธ์ที่แน่นอน

thinking_budget (ไม่แนะนำอีกต่อไป)

เราไม่แนะนำให้ใช้พารามิเตอร์ thinking_budget ที่เป็นตัวเลขดิบในโมเดล Gemini 3.x ทั้งหมดอีกต่อไป ให้ใช้ Enum สตริง thinking_level แทน

# ⚠️ Before (not recommended)
generation_config = {
    "thinking": {"thinking_budget": 7500},
}

# ✅ After
generation_config = {
    "thinking": {"thinking_level": "medium"},
}

ค่าที่ใช้ได้ ได้แก่ minimal, low, medium (ค่าเริ่มต้น) และ high

การเรียกใช้ฟังก์ชัน: การจับคู่การตอบกลับที่เข้มงวด

Interactions API จะแสดงข้อผิดพลาดเมื่อการตอบกลับฟังก์ชันไม่ตรงกันอยู่แล้ว GenerateContent API ยังไม่แสดงข้อผิดพลาด แต่การตอบกลับที่ไม่ตรงกันจะทำให้โมเดลแสดงการตอบกลับที่ว่างเปล่าพร้อม finish_reason: STOP ในกรณีส่วนใหญ่ โปรดปฏิบัติตามข้อกำหนดต่อไปนี้เสมอ

ข้อกำหนด รายละเอียด
รวม id FunctionResponse ทุกรายการต้องมี id จาก FunctionCall ที่เกี่ยวข้อง
จับคู่ name name ในการตอบกลับต้องตรงกับ name ในการเรียกใช้
จับคู่จำนวน แสดง FunctionResponse 1 รายการสำหรับ FunctionCall แต่ละรายการที่ได้รับ

Python

# ✅ Include matching call_id and name in the function_result
final_interaction = client.interactions.create(
    model="gemini-3.5-flash",
    previous_interaction_id=interaction.id,
    tools=[my_tool],
    input=[{
        "type": "function_result",
        "name": fc_step.name,
        "call_id": fc_step.id,
        "result": [{"type": "text", "text": json.dumps(result)}],
    }],
)

JavaScript

// ✅ Include matching call_id and name in the function_result
const finalInteraction = await client.interactions.create({
  model: "gemini-3.5-flash",
  previousInteractionId: interaction.id,
  tools: [myTool],
  input: [{
    type: "function_result",
    name: fcStep.name,
    call_id: fcStep.id,
    result: [{ type: "text", text: JSON.stringify(result) }],
  }],
});

Java

import java.util.Arrays;
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
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.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;

Client client = new Client();

// Assumes interactionId, callId, functionName, myTool, and resultJson from previous step
String interactionId = "interaction-id-123";
String callId = "call-id-123";
String functionName = "get_weather";
Function myTool = Function.builder().name(functionName).build();
String resultJson = "{\"temperature\": \"72F\"}";

// ✅ Include matching callId and name in the FunctionResultStep
FunctionResultStep functionResult =
    FunctionResultStep.builder()
        .name(functionName)
        .callId(callId)
        .result(
            FunctionResultStepResultUnion.of(
                Arrays.asList(TextContent.builder().text(resultJson).build())))
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.5-flash"))
        .previousInteractionId(interactionId)
        .tools(Arrays.asList(myTool))
        .input(InteractionsInput.ofStep(Arrays.asList(functionResult)))
        .build();

Interaction finalInteraction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

Go

package main

import (
    "context"
    "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)
    }

    // Assumes interactionID, callID, functionName, myTool, and resultJSON from previous step
    interactionID := "interaction-id-123"
    callID := "call-id-123"
    functionName := "get_weather"
    myTool := interactions.NewTool(interactions.Function{Name: genai.Ptr(functionName)})
    resultJSON := `{"temperature": "72F"}`

    // ✅ Include matching CallID and Name in the FunctionResultStep
    functionResult := interactions.NewStep(interactions.FunctionResultStep{
        Name:   genai.Ptr(functionName),
        CallID: callID,
        Result: interactions.NewFunctionResultStepResultUnion([]interactions.FunctionResultSubcontent{
            interactions.NewFunctionResultSubcontent(interactions.TextContent{Text: resultJSON}),
        }),
    })

    finalRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model:                 interactions.Model("gemini-3.5-flash"),
            PreviousInteractionID: genai.Ptr(interactionID),
            Tools:                 []interactions.Tool{myTool},
            Input:                 interactions.NewInteractionsInput([]interactions.Step{functionResult}),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    _ = finalRes
}

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.5-flash",
    "previous_interaction_id": "<INTERACTION_ID>",
    "tools": [...],
    "input": [{
      "type": "function_result",
      "name": "my_function",
      "call_id": "<CALL_ID>",
      "result": [{"type": "text", "text": "..."}]
    }]
  }'

การตอบกลับฟังก์ชันแบบมัลติโมดัล

เรามักจะเห็นลูกค้าใส่รูปภาพไว้นอกการตอบกลับฟังก์ชัน ซึ่งอาจทำให้โมเดลมีลักษณะการทำงานที่ไม่คาดคิด (เช่น การรั่วไหลขององค์ความรู้) และส่งผลให้เอาต์พุตมีคุณภาพต่ำลง โปรดทำตามคำแนะนำใน เอกสารประกอบเกี่ยวกับ API การตอบกลับฟังก์ชันแบบมัลติโมดัล แทน และรวมเนื้อหาแบบมัลติโมดัลไว้ในส่วนการตอบกลับฟังก์ชันที่คุณ ส่งไปยังโมเดล โมเดลสามารถประมวลผลเนื้อหาแบบมัลติโมดัลนี้ในรอบถัดไปเพื่อสร้างการตอบกลับที่มีข้อมูลมากขึ้น

Python

# ✅ Include multimodal content in the function response
final_interaction = client.interactions.create(
    model="gemini-3.5-flash",
    previous_interaction_id=interaction.id,
    input=[
        {
            "type": "function_result",
            "name": tool_call.name,
            "call_id": tool_call.id,
            "result": [
                {"type": "text", "text": "instrument.jpg"},
                {
                    "type": "image",
                    "mime_type": "image/jpeg",
                    "data": base64_image_data,
                },
            ],
        }
    ],
)

JavaScript

// ✅ Include multimodal content in the function response
const finalInteraction = await client.interactions.create({
  model: "gemini-3.5-flash",
  previousInteractionId: interaction.id,
  input: [{
    type: "function_result",
    name: toolCall.name,
    call_id: toolCall.id,
    result: [
      { type: "text", text: "instrument.jpg" },
      {
        type: "image",
        mime_type: "image/jpeg",
        data: base64ImageData,
      },
    ],
  }],
});

Java

import java.util.Arrays;
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
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.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;

Client client = new Client();

// Assumes interactionId, callId, functionName, and base64ImageData from previous step
String interactionId = "interaction-id-123";
String callId = "call-id-123";
String functionName = "get_instrument_image";
String base64ImageData = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";

// ✅ Include multimodal content in the function response
FunctionResultStep functionResult =
    FunctionResultStep.builder()
        .name(functionName)
        .callId(callId)
        .result(
            FunctionResultStepResultUnion.of(
                Arrays.asList(
                    TextContent.builder().text("instrument.jpg").build(),
                    ImageContent.builder()
                        .mimeType(ImageContentMimeType.IMAGE_JPEG)
                        .data(base64ImageData)
                        .build())))
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.5-flash"))
        .previousInteractionId(interactionId)
        .input(InteractionsInput.ofStep(Arrays.asList(functionResult)))
        .build();

Interaction finalInteraction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

Go

package main

import (
    "context"
    "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)
    }

    // Assumes interactionID, callID, functionName, and base64ImageData from previous step
    interactionID := "interaction-id-123"
    callID := "call-id-123"
    functionName := "get_instrument_image"
    base64ImageData := "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII="

    // ✅ Include multimodal content in the function response
    functionResult := interactions.NewStep(interactions.FunctionResultStep{
        Name:   genai.Ptr(functionName),
        CallID: callID,
        Result: interactions.NewFunctionResultStepResultUnion([]interactions.FunctionResultSubcontent{
            interactions.NewFunctionResultSubcontent(interactions.TextContent{
                Text: "instrument.jpg",
            }),
            interactions.NewFunctionResultSubcontent(interactions.ImageContent{
                MimeType: interactions.ImageContentMimeType("image/jpeg").ToPointer(),
                Data:     genai.Ptr(base64ImageData),
            }),
        }),
    })

    finalRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model:                 interactions.Model("gemini-3.5-flash"),
            PreviousInteractionID: genai.Ptr(interactionID),
            Input:                 interactions.NewInteractionsInput([]interactions.Step{functionResult}),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    _ = finalRes
}

คำแนะนำแบบอินไลน์ในการตอบกลับฟังก์ชัน

เรามักจะเห็นลูกค้าให้คำแนะนำเพิ่มเติมพร้อมกับการตอบกลับฟังก์ชันเป็น Parts ที่ตามมา ซึ่งอาจทำให้โมเดลมีลักษณะการทำงานที่ไม่คาดคิด (เช่น การรั่วไหลขององค์ความรู้) และส่งผลให้เอาต์พุตมีคุณภาพต่ำลง ให้เพิ่มคำแนะนำพิเศษต่อท้ายข้อความการตอบกลับฟังก์ชันโดยคั่นด้วยบรรทัดใหม่ 2 บรรทัดแทน

Python

# ✅ Append inline instructions to the end of the function response separated by two newlines
result_text = f"{json.dumps(result)}\n\n<your inline instructions>"

final_interaction = client.interactions.create(
    model="gemini-3.5-flash",
    previous_interaction_id=interaction.id,
    tools=[my_tool],
    input=[{
        "type": "function_result",
        "name": fc_step.name,
        "call_id": fc_step.id,
        "result": [{"type": "text", "text": result_text}],
    }],
)

JavaScript

// ✅ Append inline instructions to the end of the function response separated by two newlines
const resultText = `${JSON.stringify(result)}\n\n<your inline instructions>`;

const finalInteraction = await client.interactions.create({
  model: "gemini-3.5-flash",
  previousInteractionId: interaction.id,
  tools: [myTool],
  input: [{
    type: "function_result",
    name: fcStep.name,
    call_id: fcStep.id,
    result: [{ type: "text", text: resultText }],
  }],
});

Java

import java.util.Arrays;
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.FunctionResultStep;
import com.google.genai.gaos.models.interactions.FunctionResultStepResultUnion;
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.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import java.util.List;

Client client = new Client();

// Assumes interactionId, callId, functionName, myTool, and resultJson from previous step
String interactionId = "interaction-id-123";
String callId = "call-id-123";
String functionName = "get_weather";
Function myTool = Function.builder().name(functionName).build();
String resultJson = "{\"temperature\": \"72F\"}";

// ✅ Append inline instructions to the end of the function response separated by two newlines
String resultText = resultJson + "\n\n<your inline instructions>";

FunctionResultStep functionResult =
    FunctionResultStep.builder()
        .name(functionName)
        .callId(callId)
        .result(
            FunctionResultStepResultUnion.of(
                Arrays.asList(TextContent.builder().text(resultText).build())))
        .build();

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.5-flash"))
        .previousInteractionId(interactionId)
        .tools(Arrays.asList(myTool))
        .input(InteractionsInput.ofStep(Arrays.asList(functionResult)))
        .build();

Interaction finalInteraction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

Go

package main

import (
    "context"
    "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)
    }

    // Assumes interactionID, callID, functionName, myTool, and resultJSON from previous step
    interactionID := "interaction-id-123"
    callID := "call-id-123"
    functionName := "get_weather"
    myTool := interactions.NewTool(interactions.Function{Name: genai.Ptr(functionName)})
    resultJSON := `{"temperature": "72F"}`

    // ✅ Append inline instructions to the end of the function response separated by two newlines
    resultText := resultJSON + "\n\n<your inline instructions>"

    functionResult := interactions.NewStep(interactions.FunctionResultStep{
        Name:   genai.Ptr(functionName),
        CallID: callID,
        Result: interactions.NewFunctionResultStepResultUnion([]interactions.FunctionResultSubcontent{
            interactions.NewFunctionResultSubcontent(interactions.TextContent{Text: resultText}),
        }),
    })

    finalRes, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model:                 interactions.Model("gemini-3.5-flash"),
            PreviousInteractionID: genai.Ptr(interactionID),
            Tools:                 []interactions.Tool{myTool},
            Input:                 interactions.NewInteractionsInput([]interactions.Step{functionResult}),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    _ = finalRes
}

การลดการเรียกใช้เครื่องมือที่ไม่จำเป็น

หากคุณพบว่ามีการเรียกใช้เครื่องมือมากเกินไป เทคนิค 2 อย่างต่อไปนี้จะช่วยลดการเรียกใช้เครื่องมือได้

  1. เริ่มต้นด้วยการลดระดับการคิด (medium, low หรือ minimal): ระดับการคิดที่สูงขึ้นจะกระตุ้นให้โมเดลใช้เครื่องมือมากขึ้นเพื่อสำรวจและ ยืนยัน ดังนั้นการลดระดับการคิดลงจะช่วยลดการเรียกใช้เครื่องมือได้

  2. เพิ่มคำแนะนำระบบ: หากยังคงมีการใช้งานมากเกินไปหลังจากปรับระดับการคิดแล้ว ให้ลองใช้พรอมต์ที่จำกัดการใช้เครื่องมือ เช่น

    You have a limited action budget of <n> tool calls. Use them efficiently.
    

ฟีเจอร์ของตระกูล Gemini 3

Gemini 3.5 Flash สืบทอดความสามารถทั้งหมดของตระกูล Gemini 3 ซึ่งรวมถึงการใช้คอมพิวเตอร์ ฟีเจอร์ที่เปิดตัวใน Gemini 3 ซึ่งจะยังคงมีอยู่ต่อไป ได้แก่

  • การคิด: บริบทการให้เหตุผลที่เข้ารหัสจะถูกเก็บรักษาไว้ในการเรียก API โดยอัตโนมัติใน Interactions API และโดยนัยใน GenerateContent
  • เอาต์พุตที่มีโครงสร้างพร้อมเครื่องมือ: รวมโหมด JSON กับเครื่องมือในตัว (การค้นหา, บริบท URL, การเรียกใช้โค้ด, การเรียกใช้ฟังก์ชัน)
  • การตอบกลับฟังก์ชันแบบมัลติโมดัล: แสดง รูปภาพ เสียง และสื่ออื่นๆ ในผลลัพธ์การเรียกใช้ฟังก์ชัน
  • การดำเนินการโค้ดพร้อมรูปภาพ: ดำเนินการโค้ดที่ ประมวลผลและสร้างรูปภาพ
  • การใช้เครื่องมือร่วมกัน: ใช้เครื่องมือในตัวและ การเรียกใช้ฟังก์ชันที่กำหนดเองในคำขอเดียวกัน
  • ความละเอียดของสื่อ: ควบคุมการจัดสรรโทเค็นสำหรับอินพุตรูปภาพ วิดีโอ และ PDF ได้อย่างละเอียด โมเดล Gemini 3 รองรับการตั้งค่าความละเอียดต่อรายการเนื้อหา (low, medium, high, ultra_high) สำหรับพรอมต์ที่มีความละเอียดผสมกัน
  • ลายเซ็นองค์ความรู้: การแสดงการให้เหตุผลภายในของโมเดลที่เข้ารหัส จำเป็นสำหรับการเรียกใช้ฟังก์ชันแบบหลายรอบในโหมดไม่เก็บสถานะ โดย Interactions API และ SDK อย่างเป็นทางการจะจัดการให้โดยอัตโนมัติ

แนวทางปฏิบัติแนะนำในการเขียนพรอมต์

โมเดล Gemini 3.x เป็นโมเดลการให้เหตุผล ซึ่งจะเปลี่ยนวิธีที่คุณควรเขียนพรอมต์

  • คำแนะนำที่แม่นยำ: เขียนให้กระชับ Gemini 3.x ตอบสนองได้ดีที่สุดต่อคำแนะนำที่ชัดเจนและตรงไปตรงมา เทคนิควิศวกรรมพรอมต์ (Prompt Engineering) ที่ละเอียดหรือซับซ้อนซึ่งออกแบบมาสำหรับโมเดลรุ่นเก่าอาจทำให้โมเดลวิเคราะห์มากเกินไป
  • ความละเอียดของเอาต์พุต: โดยค่าเริ่มต้น Gemini 3 และ 3.1 จะมีความละเอียดน้อยกว่าและชอบคำตอบที่ตรงไปตรงมาและมีประสิทธิภาพ หากกรณีการใช้งานของคุณต้องใช้โทนการสนทนา ให้กำหนดให้โมเดลใช้โทนนั้นอย่างชัดเจนในพรอมต์ (เช่น "อธิบายเรื่องนี้ในฐานะผู้ช่วยที่เป็นมิตรและช่างพูด")
  • การจัดการบริบท: เมื่อทำงานกับชุดข้อมูลขนาดใหญ่ (เช่น หนังสือทั้งเล่ม ฐานโค้ด หรือวิดีโอยาว) ให้วางคำแนะนำหรือคำถามเฉพาะไว้ที่ส่วนท้ายของพรอมต์หลังจากบริบทข้อมูล ยึดการให้เหตุผลของโมเดลโดยเริ่มคำถามด้วยวลี เช่น "จากข้อมูลข้างต้น..."

ดูข้อมูลเพิ่มเติมเกี่ยวกับกลยุทธ์การออกแบบพรอมต์ได้ใน คู่มือวิศวกรรมพรอมต์ (Prompt Engineering)

ข้อจำกัด

  • Gemini 3.x ไม่รองรับการแบ่งส่วนรูปภาพ สำหรับเวิร์กโหลดการแบ่งส่วน ให้ใช้ Gemini 2.5 Flash ต่อไปโดยปิดการคิด

คำถามที่พบบ่อย

  1. Gemini 3.5 Flash มีข้อมูลล่าสุดถึงเมื่อใด Gemini 3.5 Flash มีข้อมูลล่าสุดถึงเดือนมกราคม 2025 หากต้องการข้อมูลล่าสุด ให้ใช้เครื่องมือ Search Grounding

  2. หน้าต่างบริบทมีขีดจำกัดเท่าใด Gemini 3.5 Flash รองรับหน้าต่างบริบทอินพุตขนาด 1 ล้านโทเค็นและโทเค็นเอาต์พุตสูงสุด 65,000 รายการ

  3. โค้ด thinking_budget เก่าของฉันจะยังใช้งานได้ไหม ได้ thinking_budget ยังคงรองรับความเข้ากันได้แบบย้อนหลัง แต่เราขอแนะนำให้ย้ายข้อมูลไปใช้ thinking_level เพื่อให้ได้ประสิทธิภาพที่คาดการณ์ได้มากขึ้น อย่าใช้ทั้ง 2 อย่างในคำขอเดียวกัน

  4. Gemini 3.5 Flash รองรับ Batch API ไหม ใช่ ดูรายละเอียดได้ในคู่มือ Batch API

  5. ระบบรองรับการแคชบริบทไหม รองรับ Context Caching

  6. เครื่องมือใดบ้างที่รองรับ Gemini 3.5 Flash รองรับ Google Search, การเชื่อมต่อแหล่งข้อมูลกับ Google Maps, File Search, การเรียกใช้โค้ด, บริบท URL และ การเรียกใช้ฟังก์ชันมาตรฐาน, ซึ่งรวมถึง การใช้เครื่องมือร่วมกัน และ การใช้คอมพิวเตอร์

โมเดลอื่นๆ

ขั้นตอนถัดไป