API تعاملات: راهنمای مهاجرت تغییرات فوری (مه ۲۰۲۶)

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

  1. طرحواره مراحل : یک آرایه steps جدید جایگزین آرایه outputs می‌شود و یک جدول زمانی ساختاریافته از هر نوبت تعامل ارائه می‌دهد.
  2. پیکربندی قالب خروجی : یک response_format چندریختی جدید، تمام کنترل‌های قالب خروجی را تجمیع کرده و response_mime_type حذف می‌کند.

برای به‌روزرسانی یکپارچه‌سازی، مراحل مربوط به نحوه مهاجرت به طرحواره جدید را دنبال کنید.

تغییر اصلی: outputs به steps

طرحواره جدید، آرایه outputs را با آرایه steps جایگزین می‌کند.

  • Legacy : پاسخ‌ها یک آرایه outputs مسطح را که فقط محتوای تولید شده مدل را شامل می‌شود، برگرداندند.
  • طرحواره جدید : پاسخ‌ها یک آرایه steps (steps array) حاوی گام‌های ساختاریافته با تفکیک‌کننده‌های نوع (type discriminators) برمی‌گردانند.

POST /interactions فقط مراحل خروجی را برمی‌گرداند. GET /interactions/{id} جدول زمانی کامل مراحل، شامل مرحله اولیه user_input برمی‌گرداند.

ورودی/خروجی پایه (یگانی)

قبل (میراث)

پایتون

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

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

جاوا اسکریپت

// 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);

استراحت

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

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

پایتون

# 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

جاوا اسکریپت

// 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);

استراحت

# 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 مسطح را با مراحل ساختاریافته جایگزین می‌کند.

قبل (میراث)

پایتون

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

جاوا اسکریپت

// 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)}`);
    }
}

استراحت

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

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

پایتون

# 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}")

جاوا اسکریپت

// 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)}`);
    }
}

استراحت

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

ابزارهای سمت سرور

ابزارهای سمت سرور (مانند جستجوی گوگل یا اجرای کد) اکنون انواع مراحل خاص را در آرایه steps ارائه می‌دهند. در حالی که طرحواره قدیمی این عملیات را به عنوان انواع محتوای خاص در آرایه outputs برمی‌گرداند، طرحواره جدید آنها را به آرایه steps منتقل می‌کند. مثال‌های زیر از جستجوی گوگل استفاده می‌کنند.

قبل (میراث)

پایتون

# 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}")

جاوا اسکریپت

// 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}`);
    }
}

استراحت

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

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

پایتون

# 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}")

جاوا اسکریپت

// 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}`);
    }
}

استراحت

# 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 ) جریان می‌دهند. برای دریافت آرگومان‌های کامل، باید این دلتاها را جمع کنید. این با فراخوانی‌های تکی که در آن شیء فراخوانی تابع کامل را به طور همزمان دریافت می‌کنید، متفاوت است.

مثال‌ها

قبل (میراث)

پایتون

# 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)

جاوا اسکریپت

// 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);
        }
    }
}

استراحت

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}}
بعد از (طرحواره جدید)

پایتون

# 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="")

جاوا اسکریپت

// 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);
        }
    }
}

استراحت

 # 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 درخواست بعدی ارسال کنید و کاربر جدید turn خود را به عنوان یک user_input step اضافه کنید.

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

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

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

  • API 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" مشخص کنید.

قبل (میراث)

پایتون

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)

جاوا اسکریپت

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);

استراحت

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

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

پایتون

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)

جاوا اسکریپت

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);

استراحت

# 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" مشخص کنید.

قبل (میراث)

پایتون

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"
        }
    },
)

جاوا اسکریپت

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

استراحت

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

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

پایتون

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"
    },
)

جاوا اسکریپت

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

استراحت

# 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 (پایتون ≥2.0.0، جاوا اسکریپت ≥2.0.0) ارتقا دهید. SDK به طور خودکار شما را در طرحواره جدید قرار می‌دهد - هیچ تغییر کدی فراتر از به‌روزرسانی نحوه خواندن پاسخ‌ها لازم نیست (به مثال‌های بالا مراجعه کنید). توجه داشته باشید که فقط طرحواره جدید در این نسخه‌های SDK پشتیبانی می‌شود. نسخه‌های قدیمی‌تر SDK (پایتون 1.xx، جاوا اسکریپت 1.xx) تا زمان حذف طرحواره قدیمی در 8 ژوئن 2026 به کار خود ادامه خواهند داد.

کاربران REST API

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

گاهشمار

تاریخ فاز کاربران SDK کاربران REST API
۷ مه انتخاب کردن نسخه جدید SDK (پایتون ≥۲.۰.۰، جاوا اسکریپت ≥۲.۰.۰) در دسترس است. برای دریافت خودکار طرحواره جدید، ارتقا دهید. برای انتخاب، هدر Api-Revision: 2026-05-20 را اضافه کنید. پیش‌فرض به قوت خود باقی می‌ماند.
۲۶ مه برگرداندن پیش‌فرض اگر قبلاً ارتقا داده شده باشد، نیازی به اقدام خاصی نیست. SDK های قدیمی‌تر (Python 1.xx، JS 1.xx) هنوز کار می‌کنند اما پاسخ‌های قدیمی را برمی‌گردانند. طرحواره جدید اکنون پیش‌فرض است. برای انصراف، هدر Api-Revision: 2026-05-07 را ارسال کنید.
۸ ژوئن غروب خورشید نسخه‌های SDK پایتون ۱.xx و جاوا اسکریپت ۱.xx برای فراخوانی‌های API تعاملات با مشکل مواجه خواهند شد. طرحواره قدیمی برای API تعاملات حذف شد. هدر Api-Revision نادیده گرفته شد.

چک لیست مهاجرت

طرحواره مراحل ( steps )

  • کد را به‌روزرسانی کنید تا محتوای پاسخ را به جای outputs ، از آرایه steps بخواند. به مثال‌ها مراجعه کنید .
  • تأیید کنید که کد شما هر دو نوع گام 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_config از generation_config به ورودی {"type": "image", ...} در response_format منتقل کنید. به مثال‌ها مراجعه کنید .
  • (چندوجهی) هنگام درخواست چندین روش خروجی response_format از یک شیء واحد به یک آرایه تبدیل کنید.