API Tương tác v1beta đang giới thiệu các thay đổi có thể gây ra lỗi, giúp tái cấu trúc hình dạng API để hỗ trợ các tính năng trong tương lai như điều hướng giữa chuyến bay và các lệnh gọi công cụ không đồng bộ. Trang này giải thích những thay đổi và cung cấp các ví dụ về mã trước và sau để giúp bạn di chuyển. Có 2 danh mục thay đổi:
- Giản đồ các bước: Một mảng
stepsmới thay thế mảngoutputs, cung cấp dòng thời gian có cấu trúc của mỗi lượt tương tác. - Cấu hình định dạng đầu ra: Một
response_formatđa hình mới hợp nhất tất cả các chế độ điều khiển định dạng đầu ra và xoáresponse_mime_type.
Hãy làm theo các bước trong phần Cách di chuyển sang giản đồ mới để cập nhật quá trình tích hợp.
Thay đổi cốt lõi: outputs thành steps
Giản đồ mới thay thế mảng outputs bằng mảng steps.
- Cũ: Các phản hồi trả về một mảng phẳng
outputschỉ chứa nội dung do mô hình tạo. - Giản đồ mới: Các phản hồi trả về một mảng
stepschứa các bước có cấu trúc với bộ phân biệt loại.
POST /interactions chỉ trả về các bước đầu ra. GET /interactions/{id}
trả về dòng thời gian đầy đủ của các bước, bao gồm cả bước user_input ban đầu.
Đầu vào/đầu ra cơ bản (đơn vị)
Trước (cũ)
Python
# Request
interaction = client.interactions.create(
model="gemini-3.5-flash", input="Tell me a joke."
)
# Response access
print(interaction.outputs[-1].text)
JavaScript
// Request
const interaction = await client.interactions.create({
model: 'gemini-3.5-flash',
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.5-flash",
"input": "Tell me a joke."
}'
// Response
{
"id": "int_123",
"role": "model",
"outputs": [
{
"type": "text",
"text": "Why did the chicken cross the road?"
}
]
}
Sau (giản đồ mới)
Python
# Request
interaction = client.interactions.create(
model="gemini-3.5-flash", input="Tell me a joke."
)
# Response access (Recommended sugar)
print(interaction.output_text)
JavaScript
// Request
const interaction = await client.interactions.create({
model: 'gemini-3.5-flash',
input: 'Tell me a joke.'
});
// Response access (Recommended sugar)
console.log(interaction.output_text);
[sdk-convenience]: /gemini-api/docs/interactions-overview#sdk-sugar
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.5-flash",
"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?"
}
]
}
]
}
Gọi hàm
Cấu trúc yêu cầu vẫn không thay đổi, nhưng phản hồi sẽ thay thế nội dung outputs phẳng bằng các bước có cấu trúc.
Trước (cũ)
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" }
}
]
}
Sau (giản đồ mới)
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" }
}
]
}
Công cụ phía máy chủ
Các công cụ phía máy chủ (như Google Tìm kiếm hoặc Thực thi mã) hiện tạo ra các loại bước cụ thể trong mảng steps. Mặc dù giản đồ cũ trả về các thao tác này dưới dạng các loại nội dung cụ thể trong mảng outputs, nhưng giản đồ mới sẽ chuyển các thao tác này vào mảng steps. Các ví dụ sau đây sử dụng Google Tìm kiếm.
Trước (cũ)
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.5-flash",
"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"
}
Sau (giản đồ mới)
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.5-flash",
"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"
}
Phát trực tiếp
Tính năng phát trực tiếp hiển thị các loại sự kiện mới:
Loại sự kiện mới
interaction.createdinteraction.completedinteraction.in_progressinteraction.requires_actionstep.startstep.deltastep.stop
Loại sự kiện không dùng nữa
Các loại sự kiện cũ sau đây được thay thế bằng các sự kiện mới được liệt kê ở trên:
interaction.start→interaction.createdcontent.start→step.startcontent.delta→step.deltacontent.stop→step.stopinteraction.complete→interaction.completedinteraction.status_update→ được thay thế bằnginteraction.in_progress,interaction.requires_action, v.v.
Lệnh gọi hàm phát trực tiếp: Khi bạn sử dụng tính năng phát trực tiếp với lệnh gọi hàm,
sự kiện step.start sẽ gửi tên hàm và các sự kiện step.delta sẽ
phát trực tiếp các đối số dưới dạng chuỗi JSON một phần (sử dụng arguments_delta). Bạn
phải tích luỹ các delta này để nhận được các đối số đầy đủ. Điều này khác với các lệnh gọi đơn vị, trong đó bạn nhận được đối tượng lệnh gọi hàm hoàn chỉnh cùng một lúc.
Ví dụ
Trước (cũ)
Python
# Legacy streaming used content.delta
stream = client.interactions.create(
model="gemini-3.5-flash",
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.5-flash',
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.5-flash",
"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}}
Sau (giản đồ mới)
Python
# Consuming stream and handling new event types
for event in client.interactions.create(
model="gemini-3.5-flash",
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.5-flash',
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.5-flash",
"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.5-flash"}, "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
Lịch sử cuộc trò chuyện không trạng thái
Nếu bạn quản lý nhật ký trò chuyện theo cách thủ công ở phía máy khách (trường hợp sử dụng không trạng thái), bạn phải cập nhật cách xâu chuỗi các lượt trước đó.
- Cũ: Nhà phát triển thường thu thập mảng
outputstừ các phản hồi và gửi lại các phản hồi đó trong trườnginputở lượt tiếp theo. - Giản đồ mới: Giờ đây, bạn nên thu thập mảng
stepstừ phản hồi và truyền mảng đó vào trườnginputcủa yêu cầu tiếp theo, thêm lượt người dùng mới dưới dạng bướcuser_input.
Cấu hình định dạng đầu ra: thay đổi response_format
API đã cập nhật hợp nhất tất cả các chế độ điều khiển định dạng đầu ra thành một trường response_format đa hình, hợp nhất. Điều này tập trung cấu hình đầu ra ở cấp cao nhất và giúp generation_config tập trung vào hành vi của mô hình (như nhiệt độ, top_p và suy nghĩ).
Thay đổi quan trọng
- API xoá
response_mime_type. Giờ đây, bạn chỉ định loại MIME cho mỗi mục định dạng bên trongresponse_format. response_formathiện là một đối tượng (hoặc mảng) đa hình. Mỗi mục có một bộ phân biệttype(text,audio,image) và các trường dành riêng cho loại. Để yêu cầu nhiều phương thức đầu ra, hãy truyền một mảng các mục định dạng.image_configchuyển từgeneration_configsangresponse_format. Giờ đây, bạn chỉ định các chế độ cài đặt đầu ra hình ảnh nhưaspect_ratiovàimage_sizetrong một mụcresponse_formatcó"type": "image".
Đầu ra có cấu trúc (JSON)
Giản đồ mới xoá trường response_mime_type. Thay vào đó, hãy chỉ định loại MIME và giản đồ JSON bên trong đối tượng response_format có
"type": "text".
Trước (cũ)
Python
interaction = client.interactions.create(
model="gemini-3.5-flash",
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.5-flash',
input: 'Summarize this article.',
response_mime_type: 'application/json',
response_format: {
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.5-flash",
"input": "Summarize this article.",
"response_mime_type": "application/json",
"response_format": {
"type": "object",
"properties": {
"summary": { "type": "string" }
}
}
}'
Sau (giản đồ mới)
Python
interaction = client.interactions.create(
model="gemini-3.5-flash",
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 response
print(interaction.output_text)
JavaScript
const interaction = await client.interactions.create({
model: 'gemini-3.5-flash',
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 response
console.log(interaction.output_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.5-flash",
"input": "Summarize this article.",
"response_format": {
"type": "text",
"mime_type": "application/json",
"schema": {
"type": "object",
"properties": {
"summary": { "type": "string" }
}
}
}
}'
Cấu hình hình ảnh
Giản đồ mới xoá image_config khỏi generation_config. Giờ đây, bạn chỉ định
các chế độ cài đặt đầu ra hình ảnh trong một response_format mục có "type": "image".
Trước (cũ)
Python
interaction = client.interactions.create(
model="gemini-3.5-flash",
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.5-flash',
input: 'Generate an image of a sunset over the ocean.',
generation_config: {
image_config: {
aspect_ratio: '1:1',
image_size: '1K'
}
},
});
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.5-flash",
"input": "Generate an image of a sunset over the ocean.",
"generation_config": {
"image_config": {
"aspect_ratio": "1:1",
"image_size": "1K"
}
}
}'
Sau (giản đồ mới)
Python
interaction = client.interactions.create(
model="gemini-3.5-flash",
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",
"aspect_ratio": "1:1",
"image_size": "1K"
},
)
JavaScript
const interaction = await client.interactions.create({
model: 'gemini-3.5-flash',
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',
aspect_ratio: '1:1',
image_size: '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.5-flash",
"input": "Generate an image of a sunset over the ocean.",
"response_format": {
"type": "image",
"mime_type": "image/jpeg",
"aspect_ratio": "1:1",
"image_size": "1K"
}
}'
Cấu hình âm thanh
Giản đồ mới thay thế response_modalities: ["audio"] bằng một mục response_format có "type": "audio".
Trước (cũ)
Python
interaction = client.interactions.create(
model="gemini-3.1-flash-tts-preview",
input="Say cheerfully: Have a wonderful day!",
response_modalities=["audio"],
generation_config={
"speech_config": [
{"voice": "Kore"}
]
}
)
JavaScript
const interaction = await client.interactions.create({
model: 'gemini-3.1-flash-tts-preview',
input: 'Say cheerfully: Have a wonderful day!',
response_modalities: ['audio'],
generation_config: {
speech_config: [
{ voice: 'Kore' }
]
},
});
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-tts-preview",
"input": "Say cheerfully: Have a wonderful day!",
"response_modalities": ["audio"],
"generation_config": {
"speech_config": [
{ "voice": "Kore" }
]
}
}'
Sau (giản đồ mới)
Python
interaction = client.interactions.create(
model="gemini-3.1-flash-tts-preview",
input="Say cheerfully: Have a wonderful day!",
# response_modalities is removed — use response_format
response_format={
"type": "audio"
},
generation_config={
"speech_config": [
{"voice": "Kore"}
]
}
)
JavaScript
const interaction = await client.interactions.create({
model: 'gemini-3.1-flash-tts-preview',
input: 'Say cheerfully: Have a wonderful day!',
// response_modalities is removed — use response_format
response_format: {
type: 'audio'
},
generation_config: {
speech_config: [
{ voice: 'Kore' }
]
},
});
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.1-flash-tts-preview",
"input": "Say cheerfully: Have a wonderful day!",
"response_format": {
"type": "audio"
},
"generation_config": {
"speech_config": [
{ "voice": "Kore" }
]
}
}'
Để yêu cầu nhiều phương thức đầu ra (ví dụ: văn bản và âm thanh cùng nhau), hãy truyền một mảng các mục định dạng vào response_format thay vì một đối tượng.
Cách di chuyển sang giản đồ mới
Người dùng SDK
Nâng cấp lên phiên bản SDK mới nhất (Python ≥2.0.0, JavaScript ≥2.0.0). SDK sẽ tự động chọn bạn sử dụng giản đồ mới – bạn không cần thay đổi mã ngoài việc cập nhật cách đọc phản hồi (xem các ví dụ ở trên). Xin lưu ý rằng chỉ giản đồ mới được hỗ trợ trong các phiên bản SDK này. Các phiên bản SDK cũ (Python 1.x.x, JavaScript 1.x.x) sẽ tiếp tục hoạt động cho đến khi giản đồ cũ bị xoá vào ngày 8 tháng 6 năm 2026.
Người dùng API REST
Hãy thêm tiêu đề Api-Revision: 2026-05-20 vào các yêu cầu để chọn sử dụng giản đồ mới ngay bây giờ. Sau ngày 26 tháng 5, giản đồ mới sẽ trở thành giản đồ mặc định cho tất cả các
yêu cầu. Bạn có thể tạm thời chọn không sử dụng bằng Api-Revision: 2026-05-07
cho đến ngày 8 tháng 6, khi API xoá vĩnh viễn giản đồ cũ.
Dòng thời gian
| Ngày | Pha ban đầu | Người dùng SDK | Người dùng API REST |
|---|---|---|---|
| Ngày 7 tháng 5 | Chọn sử dụng | Đã có phiên bản SDK mới (Python ≥2.0.0, JS ≥2.0.0). Hãy nâng cấp để tự động nhận giản đồ mới. | Thêm tiêu đề Api-Revision: 2026-05-20 để chọn sử dụng. Giản đồ mặc định vẫn là giản đồ cũ. |
| Ngày 26 tháng 5 | Lật mặc định | Bạn không cần làm gì nếu đã nâng cấp. Các SDK cũ (Python 1.x.x, JS 1.x.x) vẫn hoạt động nhưng trả về các phản hồi cũ. | Giản đồ mới hiện là giản đồ mặc định. Gửi tiêu đề Api-Revision: 2026-05-07 để chọn không sử dụng. |
| Ngày 8 tháng 6 | Hoàng hôn | Các phiên bản SDK Python 1.x.x và JS 1.x.x sẽ gặp lỗi đối với các lệnh gọi API Tương tác. | Đã xoá giản đồ cũ cho Interactions API. Tiêu đề Api-Revision bị bỏ qua. |
Danh sách kiểm tra di chuyển
Giản đồ các bước (steps)
- Cập nhật mã để đọc nội dung phản hồi từ mảng
stepsthay vìoutputs. Xem ví dụ. - Xác minh rằng mã của bạn xử lý cả loại bước
user_inputvàmodel_output. Xem ví dụ. - (Gọi hàm) Cập nhật mã để tìm các bước
function_calltrong mảngsteps. Xem ví dụ. - (Công cụ phía máy chủ) Cập nhật mã để xử lý các bước dành riêng cho công cụ (ví dụ:
google_search_call,google_search_result). Xem ví dụ. - (Nhật ký không trạng thái) Cập nhật tính năng quản lý nhật ký để truyền mảng
stepsvào trườnginputcủa yêu cầu tiếp theo. Xem chi tiết. - (Chỉ phát trực tiếp) Cập nhật máy khách để theo dõi các loại sự kiện SSE mới (
interaction.created,step.delta, v.v.). Xem ví dụ.
Cấu hình định dạng đầu ra (response_format)
- Thay thế
response_mime_typebằng trườngmime_typebên trongresponse_format. Xem ví dụ. - Bọc giản đồ JSON
response_formathiện có bên trong đối tượng{"type": "text", "schema": ...}. Xem ví dụ. - (Tạo hình ảnh) Di chuyển
image_configtừgeneration_configsang mục{"type": "image", ...}trongresponse_format. Xem ví dụ. - (Tạo lời nói) Thay thế
response_modalities=["audio"]bằng mục{"type": "audio"}trongresponse_format. Xem ví dụ. - (Đa phương thức) Chuyển đổi
response_formattừ một đối tượng thành một mảng khi yêu cầu nhiều phương thức đầu ra.