API การโต้ตอบ: คู่มือการย้ายข้อมูลการเปลี่ยนแปลงที่ไม่รองรับการทำงานย้อนหลัง (พฤษภาคม 2026)

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

  1. สคีมาขั้นตอน: อาร์เรย์ steps ใหม่จะแทนที่อาร์เรย์ outputs เพื่อให้ไทม์ไลน์ที่มีโครงสร้างของการโต้ตอบแต่ละรอบ
  2. การกำหนดค่ารูปแบบเอาต์พุต: Polymorphic response_format ใหม่จะรวมการควบคุมรูปแบบเอาต์พุตทั้งหมดและนำ response_mime_typeออก

ทำตามขั้นตอนในวิธีย้ายข้อมูลไปยังสคีมาใหม่เพื่ออัปเดตการผสานรวม

การเปลี่ยนแปลงหลัก: outputs เป็น steps

โดยสคีมาใหม่จะแทนที่อาร์เรย์ outputs ด้วยอาร์เรย์ steps

  • เดิม: การตอบกลับจะแสดงอาร์เรย์ outputs แบบเรียบที่มีเฉพาะเนื้อหาที่โมเดลสร้างขึ้น
  • สคีมาใหม่: คำตอบจะแสดงอาร์เรย์ steps ที่มีขั้นตอนที่มีโครงสร้างพร้อมตัวแยกประเภท

POST /interactions จะแสดงเฉพาะขั้นตอนเอาต์พุต GET /interactions/{id} แสดงไทม์ไลน์ขั้นตอนทั้งหมด รวมถึงขั้นตอน user_input เริ่มต้น

อินพุต/เอาต์พุตพื้นฐาน (เอกภาค)

ก่อน (เวอร์ชันเดิม)

Python

# Request
interaction = client.interactions.create(
    model="gemini-3-flash-preview", input="Tell me a joke."
)

# Response access
print(interaction.outputs[-1].text)

JavaScript

// Request
const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Tell me a joke.'
});

// Response access
console.log(interaction.outputs[-1].text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Tell me a joke."
  }'
// Response
{
  "id": "int_123",
  "role": "model",
  "outputs": [
    {
      "type": "text",
      "text": "Why did the chicken cross the road?"
    }
  ]
}

หลังจาก (สคีมาใหม่)

Python

# Request
interaction = client.interactions.create(
    model="gemini-3-flash-preview", input="Tell me a joke."
)

# Response access
print(interaction.steps[-1].content[0].text)  # CHANGED: steps instead of outputs

JavaScript

// Request
const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Tell me a joke.'
});

// Response access
console.log(interaction.steps.at(-1).content[0].text);

REST

# Opt-in needed before May 26th
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Tell me a joke."
  }'
// POST Response
{
  "id": "int_123",
  "steps": [
    {
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "Why did the chicken cross the road?"
        }
      ]
    }
  ]
}

// GET /v1beta/interactions/int_123 (returns full timeline including input)
{
  "id": "int_123",
  "steps": [
    {
      "type": "user_input",
      "content": [
        { "type": "text", "text": "Tell me a joke." }
      ]
    },
    {
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "Why did the chicken cross the road?"
        }
      ]
    }
  ]
}

การเรียกใช้ฟังก์ชัน

โครงสร้างคำขอจะยังคงเหมือนเดิม แต่การตอบกลับจะแทนที่เนื้อหาoutputsแบบเรียบด้วยขั้นตอนที่มีโครงสร้าง

ก่อน (เวอร์ชันเดิม)

Python

# Accessing function call in legacy schema
for output in interaction.outputs:
    if output.type == "function_call":
        print(f"Calling {output.name} with {output.arguments}")

JavaScript

// Accessing function call in legacy schema
for (const output of interaction.outputs) {
    if (output.type === 'function_call') {
        console.log(`Calling {output.name} with {JSON.stringify(output.arguments)}`);
    }
}

REST

// Response
{
  "id": "int_001",
  "role": "model",
  "status": "requires_action",
  "outputs": [
    {
      "type": "thought",
      "signature": "abc123..."
    },
    {
      "type": "function_call",
      "id": "fc_1",
      "name": "get_weather",
      "arguments": { "location": "Boston, MA" }
    }
  ]
}

หลังจาก (สคีมาใหม่)

Python

# Accessing function call in new steps schema
for step in interaction.steps:
    if step.type == "function_call":
        print(f"Calling {step.name} with {step.arguments}")

JavaScript

// Accessing function call in new steps schema
for (const step of interaction.steps) {
    if (step.type === 'function_call') {
        console.log(`Calling {step.name} with {JSON.stringify(step.arguments)}`);
    }
}

REST

// POST Response
{
  "id": "int_001",
  "status": "requires_action",
  "steps": [
    {
      "type": "thought",
      "summary": [{
        "type": "text",
        "text": "I need to check the weather in Boston..."
      }],
      "signature": "abc123..."
    },
    {
      "type": "function_call",
      "id": "fc_1",
      "name": "get_weather",
      "arguments": { "location": "Boston, MA" }
    }
  ]
}

เครื่องมือฝั่งเซิร์ฟเวอร์

ตอนนี้เครื่องมือฝั่งเซิร์ฟเวอร์ (เช่น Google Search หรือการเรียกใช้โค้ด) จะให้ประเภทขั้นตอนที่เฉพาะเจาะจงในอาร์เรย์ steps ในขณะที่สคีมาเดิมแสดงผลการดำเนินการเหล่านี้เป็นประเภทเนื้อหาที่เฉพาะเจาะจงภายในอาร์เรย์ outputs สคีมาใหม่จะย้ายการดำเนินการเหล่านี้ไปยังอาร์เรย์ steps ตัวอย่างต่อไปนี้ใช้ Google Search

ก่อน (เวอร์ชันเดิม)

Python

# Accessing search results in legacy schema
for output in interaction.outputs:
    if output.type == "google_search_call":
        print(f"Searched for: {output.arguments.queries}")
    elif output.type == "google_search_result":
        print(f"Found results: {output.result.rendered_content}")

JavaScript

// Accessing search results in legacy schema
for (const output of interaction.outputs) {
    if (output.type === 'google_search_call') {
        console.log(`Searched for: {output.arguments.queries}`);
    } else if (output.type === 'google_search_result') {
        console.log(`Found results: {output.result.renderedContent}`);
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Who won the last Super Bowl?",
    "tools": [
      { "type": "google_search" }
    ]
  }'
// Response
{
  "id": "int_456",
  "outputs": [
    {
      "type": "google_search_call",
      "id": "gs_1",
      "arguments": { "queries": ["last Super Bowl winner"] }
    },
    {
      "type": "google_search_result",
      "call_id": "gs_1",
      "result": {
        "rendered_content": "<div>...</div>",
        "url": "https://www.nfl.com/super-bowl"
      }
    },
    {
      "type": "text",
      "text": "The Kansas City Chiefs won the last Super Bowl.",
      "annotations": [
        {
          "start_index": 4,
          "end_index": 22,
          "source": "https://www.nfl.com/super-bowl"
        }
      ]
    }
  ],
  "status": "completed"
}

หลังจาก (สคีมาใหม่)

Python

# Accessing search results in new steps schema
for step in interaction.steps:
    if step.type == "google_search_call":
        print(f"Searched for: {step.arguments.queries}")
    elif step.type == "google_search_result":
        print(f"Found results: {step.result.search_suggestions}")

JavaScript

// Accessing search results in new steps schema
for (const step of interaction.steps) {
    if (step.type === 'google_search_call') {
        console.log(`Searched for: {step.arguments.queries}`);
    } else if (step.type === 'google_search_result') {
        console.log(`Found results: {step.result.searchSuggestions}`);
    }
}

REST

# Opt-in needed before May 26th
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Who won the last Super Bowl?",
    "tools": [
      { "type": "google_search" }
    ]
  }'
// POST Response
{
  "id": "int_456",
  "steps": [
    {
      "type": "google_search_call",
      "id": "gs_1",
      "arguments": { "queries": ["last Super Bowl winner"] },
      "signature": "abc123..."
    },
    {
      "type": "google_search_result",
      "call_id": "gs_1",
      "result": {
        "search_suggestions": "<div>...</div>"
      },
      "signature": "abc123..."
    },
    {
      "type": "model_output",
      "content": [
        {
          "type": "text",
          "text": "The Kansas City Chiefs won the last Super Bowl.",
          "annotations": [
            {
              "type": "url_citation",
              "url": "https://www.nfl.com/super-bowl",
              "title": "NFL.com",
              "start_index": 4,
              "end_index": 22
            }
          ]
        }
      ]
    }
  ],
  "status": "completed"
}

สตรีมมิง

การสตรีมจะแสดงเหตุการณ์ประเภทใหม่ดังนี้

ประเภทกิจกรรมใหม่

  • interaction.created
  • interaction.completed
  • interaction.in_progress
  • interaction.requires_action
  • interaction.error
  • step.start
  • step.delta
  • step.stop

ประเภทเหตุการณ์ที่เลิกใช้งานแล้ว

ระบบจะแทนที่เหตุการณ์ประเภทเดิมต่อไปนี้ด้วยเหตุการณ์ใหม่ที่แสดงไว้ข้างต้น

  • interaction.startinteraction.created
  • content.startstep.start
  • content.deltastep.delta
  • content.stopstep.stop
  • interaction.completeinteraction.completed
  • errorinteraction.error
  • interaction.status_update → แทนที่ด้วย interaction.in_progress, interaction.requires_action ฯลฯ

การเรียกใช้ฟังก์ชันแบบสตรีม: เมื่อใช้การสตรีมกับการเรียกใช้ฟังก์ชัน เหตุการณ์ step.start จะแสดงชื่อฟังก์ชัน และเหตุการณ์ step.delta จะสตรีมอาร์กิวเมนต์เป็นสตริง JSON บางส่วน (โดยใช้ arguments_delta) คุณ ต้องสะสมส่วนต่างเหล่านี้เพื่อรับอาร์กิวเมนต์ทั้งหมด ซึ่งแตกต่างจาก การเรียกแบบเอกภาคที่คุณจะได้รับออบเจ็กต์การเรียกใช้ฟังก์ชันที่สมบูรณ์ในครั้งเดียว

ตัวอย่าง

ก่อน (เดิม)

Python

# Legacy streaming used content.delta
stream = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Explain quantum entanglement in simple terms.",
    stream=True,
)

for chunk in stream:
    if chunk.event_type == "content.delta":
        if chunk.delta.type == "text":
            print(chunk.delta.text, end="", flush=True)

JavaScript

// Legacy streaming used content.delta
const stream = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Explain quantum entanglement in simple terms.',
    stream: true,
});

for await (const chunk of stream) {
    if (chunk.event_type === 'content.delta') {
        if (chunk.delta.type === 'text') {
            process.stdout.write(chunk.delta.text);
        }
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Explain quantum entanglement in simple terms.",
    "stream": true
  }'
// Response (SSE Lines)
// event: interaction.start
// data: {"id": "int_123", "status": "in_progress"}
//
// event: content.start
// data: {"index": 0, "type": "text"}
//
// event: content.delta
// data: {"delta": {"type": "text", "text": "Quantum entanglement is..."}}
//
// event: content.stop
// data: {"index": 0}
//
// event: interaction.complete
// data: {"id": "int_123", "status": "done", "usage": {"total_tokens": 42}}
หลังการปรับ (สคีมาใหม่)

Python

# Consuming stream and handling new event types
for event in client.interactions.create(
    model="gemini-3-flash-preview",
    input="Tell me a story.",
    stream=True,
):
    if event.type == "step.delta":  # CHANGED: step.delta instead of content.delta
        if event.delta.type == "text":
            print(event.delta.text, end="")

JavaScript

// Consuming stream and handling new event types
const stream = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Tell me a story.',
    stream: true,
});

for await (const event of stream) {
    if (event.type === 'step.delta') {  // CHANGED: step.delta instead of content.delta
        if (event.delta.type === 'text') {
            process.stdout.write(event.delta.text);
        }
    }
}

REST

 # Opt-in needed before May 26th
 curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
   -H "Content-Type: application/json" \
   -H "Accept: text/event-stream" \
   -H "Api-Revision: 2026-05-20" \
   -d '{
     "model": "gemini-3-flash-preview",
     "input": "Tell me a story.",
     "stream": true
   }'
 // Response (SSE Lines)
 // event: interaction.created
 // data: {"interaction": {"id": "int_xyz", "status": "in_progress", "object": "interaction", "model": "gemini-3-flash-preview"}, "event_type": "interaction.created"}
 //
 // event: interaction.in_progress
 // data: {"interaction_id": "int_xyz", "event_type": "interaction.in_progress"}
 //
 // event: step.start
 // data: {"index": 0, "step": {"type": "thought", "signature": "abc123..."}, "event_type": "step.start"}
 //
 // event: step.stop
 // data: {"index": 0, "event_type": "step.stop"}
 //
 // event: step.start
 // data: {"index": 1, "step": {"content": [{"text": "Once upon", "type": "text"}], "type": "model_output"}, "event_type": "step.start"}
 //
 // event: step.delta
 // data: {"index": 1, "delta": {"text": " a time...", "type": "text"}, "event_type": "step.delta"}
 //
 // event: step.stop
 // data: {"type": "step.stop", "index": 1, "status": "done"}
 //
 // event: interaction.completed
 // data: {"type": "interaction.completed", "interaction": {"id": "int_xyz", "status": "completed", "usage": {"prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15}}} // NEW: Dedicated completion event

ประวัติการสนทนาแบบไม่เก็บสถานะ

หากคุณจัดการประวัติการสนทนาด้วยตนเองในฝั่งไคลเอ็นต์ (กรณีการใช้งานแบบไม่เก็บสถานะ) คุณต้องอัปเดตวิธีเชื่อมโยงเทิร์นก่อนหน้า

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

การกำหนดค่ารูปแบบเอาต์พุต: response_format การเปลี่ยนแปลง

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

การเปลี่ยนแปลงที่สำคัญ

  • API จะนำ response_mime_type ออก ตอนนี้คุณระบุประเภท MIME ต่อรายการรูปแบบภายใน response_format ได้แล้ว
  • ตอนนี้ response_format เป็นออบเจ็กต์ (หรืออาร์เรย์) แบบ Polymorphic แล้ว แต่ละรายการมีตัวแยกแยะ type (text, audio, image) และฟิลด์เฉพาะประเภท หากต้องการขอเอาต์พุตหลายรูปแบบ ให้ส่งอาร์เรย์ของรายการรูปแบบ
  • image_config ย้ายจาก generation_config ไปยัง response_format ตอนนี้คุณระบุการตั้งค่าเอาต์พุตรูปภาพ เช่น aspect_ratio และ image_size ในรายการ response_format ด้วย "type": "image" ได้แล้ว

เอาต์พุตที่มีโครงสร้าง (JSON)

สคีมาใหม่จะนำฟิลด์ response_mime_type ออก ให้ระบุประเภท MIME และสคีมา JSON ภายในออบเจ็กต์ response_format ที่มี "type": "text" แทน

ก่อน (เวอร์ชันเดิม)

Python

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Summarize this article.",
    response_mime_type="application/json",
    response_format={
        "type": "object",
        "properties": {
            "summary": {"type": "string"}
        }
    },
)

print(interaction.outputs[-1].text)

JavaScript

const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Summarize this article.',
    responseMimeType: 'application/json',
    responseFormat: {
        type: 'object',
        properties: {
            summary: { type: 'string' }
        }
    },
});

console.log(interaction.outputs[-1].text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Summarize this article.",
    "response_mime_type": "application/json",
    "response_format": {
      "type": "object",
      "properties": {
        "summary": { "type": "string" }
      }
    }
  }'

หลังจาก (สคีมาใหม่)

Python

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Summarize this article.",
    # response_mime_type is removed — specify mime_type inside response_format
    response_format={
        "type": "text",
        "mime_type": "application/json",
        "schema": {
            "type": "object",
            "properties": {
                "summary": {"type": "string"}
            }
        }
    },
)

print(interaction.steps[-1].content[0].text)

JavaScript

const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Summarize this article.',
    // responseMimeType is removed — specify mimeType inside responseFormat
    responseFormat: {
        type: 'text',
        mimeType: 'application/json',
        schema: {
            type: 'object',
            properties: {
                summary: { type: 'string' }
            }
        }
    },
});

console.log(interaction.steps.at(-1).content[0].text);

REST

# Opt-in needed before May 26th
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Summarize this article.",
    "response_format": {
      "type": "text",
      "mime_type": "application/json",
      "schema": {
        "type": "object",
        "properties": {
          "summary": { "type": "string" }
        }
      }
    }
  }'

การกำหนดค่ารูปภาพ

สคีมาใหม่จะนำ image_config ออกจาก generation_config ตอนนี้คุณระบุ การตั้งค่าเอาต์พุตรูปภาพในรายการ response_format ด้วย "type": "image"

ก่อน (เวอร์ชันเดิม)

Python

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Generate an image of a sunset over the ocean.",
    generation_config={
        "image_config": {
            "aspect_ratio": "1:1",
            "image_size": "1K"
        }
    },
)

JavaScript

const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Generate an image of a sunset over the ocean.',
    generationConfig: {
        imageConfig: {
            aspectRatio: '1:1',
            imageSize: '1K'
        }
    },
});

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Generate an image of a sunset over the ocean.",
    "generation_config": {
      "image_config": {
        "aspect_ratio": "1:1",
        "image_size": "1K"
      }
    }
  }'

หลังจาก (สคีมาใหม่)

Python

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Generate an image of a sunset over the ocean.",
    # image_config is removed from generation_config — use response_format
    response_format={
        "type": "image",
        "mime_type": "image/jpeg",
        "delivery": "inline",
        "aspect_ratio": "1:1",
        "image_size": "1K"
    },
)

JavaScript

const interaction = await client.interactions.create({
    model: 'gemini-3-flash-preview',
    input: 'Generate an image of a sunset over the ocean.',
    // imageConfig is removed from generationConfig — use responseFormat
    responseFormat: {
        type: 'image',
        mimeType: 'image/jpeg',
        delivery: 'inline',
        aspectRatio: '1:1',
        imageSize: '1K'
    },
});

REST

# Opt-in needed before May 26th
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Generate an image of a sunset over the ocean.",
    "response_format": {
      "type": "image",
      "mime_type": "image/jpeg",
      "delivery": "inline",
      "aspect_ratio": "1:1",
      "image_size": "1K"
    }
  }'

หากต้องการขอเอาต์พุตหลายรูปแบบ (เช่น ข้อความและเสียงพร้อมกัน) ให้ส่งอาร์เรย์ของรายการรูปแบบไปยัง response_format แทนที่จะส่งออบเจ็กต์เดียว

วิธีย้ายข้อมูลไปยังสคีมาใหม่

ผู้ใช้ SDK

อัปเกรดเป็น SDK เวอร์ชันล่าสุด (Python ≥2.0.0, JavaScript ≥2.0.0) SDK จะเลือกใช้สคีมาใหม่ให้คุณโดยอัตโนมัติ โดยไม่ต้องเปลี่ยนแปลงโค้ดใดๆ นอกเหนือจาก การอัปเดตวิธีอ่านการตอบกลับ (ดูตัวอย่างด้านบน) โปรดทราบว่า SDK เวอร์ชันเหล่านี้รองรับเฉพาะสคีมาใหม่ เท่านั้น SDK เวอร์ชันเก่า (Python 1.x.x, JavaScript 1.x.x) จะยังคงทำงานต่อไปจนกว่าจะนำสคีมาเดิมออกในวันที่ 8 มิถุนายน 2026

ผู้ใช้ REST API

เพิ่มส่วนหัว Api-Revision: 2026-05-20 ลงในคำขอเพื่อเลือกใช้สคีมาใหม่ตอนนี้ หลังจากวันที่ 26 พฤษภาคม สคีมาใหม่จะกลายเป็นค่าเริ่มต้นสำหรับคำขอทั้งหมด คุณเลือกไม่ใช้ชั่วคราวได้ด้วย Api-Revision: 2026-05-07 จนถึงวันที่ 8 มิถุนายน ซึ่งเป็นวันที่ API จะนำสคีมาเดิมออกอย่างถาวร

ไทม์ไลน์

วันที่ ระยะ ผู้ใช้ SDK ผู้ใช้ REST API
7 พฤษภาคม เลือกเข้าร่วม มี SDK เวอร์ชันใหม่ (Python ≥2.0.0, JS ≥2.0.0) อัปเกรดเพื่อรับสคีมาใหม่โดยอัตโนมัติ เพิ่มส่วนหัว Api-Revision: 2026-05-20 เพื่อเลือกใช้ ค่าเริ่มต้นยังคงเป็นเวอร์ชันเดิม
26 พฤษภาคม การพลิกเริ่มต้น คุณไม่ต้องดำเนินการใดๆ หากอัปเกรดแล้ว SDK รุ่นเก่า (Python 1.x.x, JS 1.x.x) ยังคงใช้งานได้ แต่จะแสดงการตอบกลับแบบเดิม ตอนนี้สคีมาใหม่เป็นค่าเริ่มต้นแล้ว ส่งส่วนหัว Api-Revision: 2026-05-07 เพื่อเลือกไม่ใช้
8 มิถุนายน พระอาทิตย์ตก SDK เวอร์ชัน Python 1.x.x และ JS 1.x.x จะใช้งานไม่ได้สำหรับการเรียก Interactions API นำสคีมาเดิมออกสำหรับ Interactions API ระบบจะไม่สนใจส่วนหัว Api-Revision

รายการตรวจสอบการย้ายข้อมูล

สคีมาขั้นตอน (steps)

  • อัปเดตโค้ดเพื่ออ่านเนื้อหาการตอบกลับจากอาร์เรย์ steps แทน outputs ดูตัวอย่าง
  • ตรวจสอบว่าโค้ดของคุณรองรับทั้งประเภทขั้นตอน user_input และ model_output ดูตัวอย่าง
  • (การเรียกใช้ฟังก์ชัน) อัปเดตโค้ดเพื่อค้นหาขั้นตอน function_call ในอาร์เรย์ steps ดูตัวอย่าง
  • (เครื่องมือฝั่งเซิร์ฟเวอร์) อัปเดตโค้ดเพื่อจัดการขั้นตอนเฉพาะเครื่องมือ (เช่น google_search_call, google_search_result) ดูตัวอย่าง
  • (ประวัติแบบไม่เก็บสถานะ) อัปเดตการจัดการประวัติเพื่อส่งอาร์เรย์ steps ในฟิลด์ input ของคำขอถัดไป ดูรายละเอียด
  • (การสตรีมเท่านั้น) อัปเดตไคลเอ็นต์เพื่อรอฟังประเภทเหตุการณ์ SSE ใหม่ (interaction.created, step.delta ฯลฯ) ดูตัวอย่าง

การกำหนดค่ารูปแบบเอาต์พุต (response_format)

  • แทนที่ response_mime_type ด้วยฟิลด์ mime_type ภายใน response_format ดูตัวอย่าง
  • ห่อหุ้มresponse_formatสคีมา JSON ที่มีอยู่ภายในออบเจ็กต์ {"type": "text", "schema": ...} ดูตัวอย่าง
  • (การสร้างรูปภาพ) ย้าย image_config จาก generation_config ไปยังรายการ {"type": "image", ...} ใน response_format ดูตัวอย่าง
  • (มัลติโมดัล) แปลง response_format จากออบเจ็กต์เดียวเป็นอาร์เรย์เมื่อขอเอาต์พุตหลายรูปแบบ