میانای برنامه‌سازی کاربردی تعاملات: راهنمای انتقال تغییرات مخرب (مه ۲۰۲۶)

‫v1beta Interactions API درحال معرفی تغییرات اساسی است که ساختار شکل API را برای پشتیبانی از قابلیت‌های آینده مانند هدایت در حین اجرا و فراخوانی‌های ابزار ناهمگام بازسازی می‌کند. این صفحه توضیح می‌دهد چه چیزی درحال تغییر است و نمونه‌های کد قبل و بعد را برای کمک به انتقال شما ارائه می‌دهد. دو دسته تغییر وجود دارد:

  1. طرح‌واره مراحل: آرایه steps جدیدی جایگزین آرایه outputs می‌شود و خط زمان ساختاریافته‌ای از هر نوبت تعامل ارائه می‌دهد.
  2. پیکربندی قالب برونداد: 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.8-flash", input="Tell me a joke."
)

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

JavaScript

// Request
const interaction = await client.interactions.create({
    model: 'gemini-3.8-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.8-flash",
    "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.8-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.8-flash',
    input: 'Tell me a joke.'
});

// Response access (Recommended sugar)
console.log(interaction.output_text);

[sdk-convenience]: /gemini-api/docs/interactions-overview#sdk-sugar

استراحت

# 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.8-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?"
        }
      ]
    }
  ]
}

فراخوانی تابع

ساختار درخواست بدون تغییر باقی می‌ماند، اما پاسخ، محتوای ساده 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» یا «اجرای کد») اکنون انواع گام‌های خاصی را در آرایه steps ارائه می‌دهند. درحالی‌که طرحواره قدیمی این عملیات‌ها را به‌عنوان انواع محتوای خاص در آرایه outputs برمی‌گرداند، طرحواره جدید آن‌ها را به آرایه steps منتقل می‌کند. در مثال‌های زیر از «جستجوی Google» استفاده شده است.

قبل (قدیمی)

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.8-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"
}

بعداز (طرح‌واره جدید)

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[0].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[0].search_suggestions}`);
    }
}

استراحت

# 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.8-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"
}

جاری‌سازی

جاری‌سازی انواع رویداد جدیدی را نشان می‌دهد:

انواع رویداد جدید

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

انواع رویداد منسوخ

انواع رویداد قدیمی زیر با رویدادهای جدید فهرست‌شده در بالا جایگزین شده‌اند:

  • interaction.start ← interaction.created
  • content.start ← step.start
  • content.delta ← step.delta
  • content.stop ← step.stop
  • interaction.complete ← interaction.completed
  • ‫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.8-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.8-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);
        }
    }
}

استراحت

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?key=$GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.8-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}}
بعداز (طرح‌واره جدید)

Python

# Consuming stream and handling new event types
for event in client.interactions.create(
    model="gemini-3.8-flash",
    input="Tell me a story.",
    stream=True,
):
    if event.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.8-flash',
    input: 'Tell me a story.',
    stream: true,
});

for await (const event of stream) {
    if (event.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.8-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.8-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

سابقه مکالمه بدون حالت

اگر سابقه مکالمه را به‌صورت دستی در سمت کارخواه مدیریت می‌کنید (مورد استفاده بدون حالت)، باید نحوه اتصال نوبت‌های قبلی را به‌روز کنید.

  • قدیمی: توسعه‌دهندگان اغلب آرایه outputs را از پاسخ‌ها جمع‌آوری می‌کردند و آن را در فیلد input در نوبت بعدی برمی‌گرداندند.
  • طرحواره جدید: اکنون باید آرایه steps را از پاسخ جمع‌آوری کنید و آن را در فیلد input درخواست بعدی بگذرانید و گردش کاربر جدیدتان را به‌عنوان مرحله user_input پیوست کنید.

پیکربندی قالب خروجی: response_format تغییر

میانای برنامه‌سازی کاربردی به‌روزشده همه کنترل‌های قالب برونداد را در یک فیلد response_format چندریختی یکپارچه می‌کند. این کار پیکربندی برونداد را در سطح بالا متمرکز می‌کند و generation_config را روی رفتار مدل (مثل دما، top_p، و تفکر) متمرکز نگه می‌دارد.

تغییرات کلیدی

  • میانای برنامه‌سازی کاربردی response_mime_type را برمی‌دارد. اکنون نوع MIME را برای هر ورودی قالب در response_format مشخص می‌کنید.
  • response_format اکنون یک شیء (یا آرایه) چندریختی است. هر ورودی دارای یک 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.8-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.8-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.8-flash",
    "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.8-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.8-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);

استراحت

# 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.8-flash",
    "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.8-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.8-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.8-flash",
    "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.8-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.8-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.8-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"
    }
  }'

پیکربندی صدا

طرحواره جدید response_modalities: ["audio"] را با ورودی response_format از "type": "audio" جایگزین می‌کند.

قبل‌از (قدیمی)

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" }
      ]
    }
  }'

بعداز (طرح‌واره جدید)

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' }
        ]
    },
});

استراحت

# 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" }
      ]
    }
  }'

برای درخواست چند روش برونداد (برای مثال، نوشتار و صدا با هم)، به‌جای یک شیء واحد، مجموعه‌ای از ورودی‌های قالب را به response_format ارسال کنید.

نحوه انتقال به طرحواره جدید

کاربران کیت توسعه نرم‌افزار

به جدیدترین نسخه کیت توسعه نرم‌افزار (Python ≥2.0.0،‏ JavaScript ≥2.0.0) ارتقا دهید. «کیت توسعه نرم‌افزار» به‌طور خودکار شما را در طرحواره جدید شرکت می‌دهد — فراتر از به‌روزرسانی نحوه خواندن پاسخ‌ها (به مثال‌های بالا مراجعه کنید)، نیازی به تغییر کد نیست. توجه داشته باشید که فقط طرحواره جدید در این نسخه‌های کیت توسعه نرم‌افزار پشتیبانی می‌شود. نسخه‌های قدیمی‌تر کیت توسعه نرم‌افزار (Python 1.x.x،‏ JavaScript 1.x.x) تا زمانی که طرح‌واره قدیمی در ۸ ژوئن ۲۰۲۶ برداشته شود همچنان کار خواهند کرد.

کاربران REST API

سرایند Api-Revision: 2026-05-20 را به درخواست‌هایتان اضافه کنید تا اکنون با طرح‌واره جدید موافقت کنید. پس‌از ۲۶ مه، طرح جدید برای همه درخواست‌ها پیش‌فرض می‌شود. می‌توانید با Api-Revision: 2026-05-07 به‌طور موقت انصراف دهید تا ۸ ژوئن که API طرح‌واره قدیمی را برای همیشه برمی‌دارد.

خط زمان

تاریخ دور کاربران کیت توسعه نرم‌افزار کاربران REST API
۷ مه شرکت کردن نسخه جدید کیت توسعه نرم‌افزار دردسترس است (Python ≥2.0.0, JS ≥2.0.0). ارتقا دهید تا طرح‌واره جدید را به‌طور خودکار دریافت کنید. برای موافقت کردن، سرایند Api-Revision: 2026-05-20 را اضافه کنید. پیش‌فرض همچنان قدیمی است.
‫۲۶ مه وارونه کردن پیش‌فرض اگر قبلاً ارتقا داده‌اید، اقدامی لازم نیست. کیت‌های توسعه نرم‌افزار قدیمی‌تر (Python 1.x.x،‏ JS 1.x.x) همچنان کار می‌کنند اما پاسخ‌های قدیمی را برمی‌گردانند. طرح‌واره جدید اکنون پیش‌فرض است. برای انصراف دادن، سرایند Api-Revision: 2026-05-07 را ارسال کنید.
۸ ژوئن غروب نسخه‌های کیت توسعه نرم‌افزار Python 1.x.x و JS 1.x.x برای فراخوانی‌های «میانای برنامه‌سازی کاربردی تعامل‌ها» ازکار خواهند افتاد. طرح قدیمی برای 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 جایگزین کنید. مثال‌ها را ببینید.
  • طرح JSON response_format موجودتان را در شیء {"type": "text", "schema": ...} قرار دهید. مثال‌ها را ببینید.
  • (Image Generation) Move image_config from generation_config to a {"type": "image", ...} entry in response_format. مثال‌ها را ببینید.
  • (تولید گفتار) response_modalities=["audio"] را با ورودی {"type": "audio"} در response_format جایگزین کنید. مثال‌ها را ببینید.
  • (چندوجهی) هنگام درخواست چندوجهی‌های برونداد، response_format را از یک شیء واحد به آرایه تبدیل کنید.