واجهة برمجة التطبيقات Interactions API: دليل نقل التغييرات غير المتوافقة (مايو 2026)

تُجري واجهة برمجة التطبيقات v1beta Interactions 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.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?"
    }
  ]
}

بعد (المخطط الجديد)

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#convenience-properties

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

استدعاء الدالة

ستبقى بنية الطلب بدون تغيير، ولكن سيتم استبدال المحتوى العادي 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.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"
}

بعد (المخطط الجديد)

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

البث

تعرض ميزة البث أنواعًا جديدة من الأحداث:

أنواع الأحداث الجديدة

  • 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.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}}
بعد (المخطط الجديد)

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

سجلّ المحادثات بدون حالة

إذا كنت تدير سجلّ المحادثات يدويًا من جهة العميل (حالة استخدام بدون حالة)، عليك تعديل طريقة ربط الردود السابقة.

  • الإصدار القديم: كان المطوّرون غالبًا يجمعون مصفوفة outputs من الردود ويرسلونها مرة أخرى في الحقل input في الجولة التالية.
  • المخطط الجديد: عليك الآن جمع مصفوفة steps من الرد وتمريرها في الحقل input للطلب التالي، مع إضافة دور المستخدم الجديد كخطوة user_input.

تغييرات في إعدادات تنسيق الإخراج: response_format

تجمع واجهة برمجة التطبيقات المعدَّلة جميع عناصر التحكّم في تنسيق الإخراج في حقل response_format موحّد ومتعدد الأشكال. يؤدي ذلك إلى تركيز إعدادات الإخراج في المستوى الأعلى، وإبقاء generation_config مركّزًا على سلوك النموذج (مثل درجة العشوائية وأعلى احتمال تراكمي والتفكير).

أهم التغييرات

  • تزيل واجهة برمجة التطبيقات 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.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" }
      }
    }
  }'

بعد (المخطط الجديد)

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

إعدادات الصور

يزيل المخطط الجديد image_config من generation_config. يمكنك الآن تحديد إعدادات إخراج الصور في إدخال response_format باستخدام "type": "image".

قبل (قديم)

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

بعد (المخطط الجديد)

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

إعدادات الصوت

يستبدل المخطط الجديد 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' }
        ]
    },
});

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

لطلب وسائط إخراج متعددة (مثل النص والصوت معًا)، مرِّر مصفوفة من إدخالات التنسيق إلى response_format بدلاً من عنصر واحد.

كيفية الانتقال إلى المخطط الجديد

مستخدمو حزمة تطوير البرامج (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 يونيو، وهو الموعد الذي ستزيل فيه واجهة برمجة التطبيقات المخطط القديم نهائيًا.

المخطط الزمني

التاريخ المرحلة مستخدمو حزمة تطوير البرامج (SDK) مستخدمو REST API
‫7 مايو اشتراك يتوفّر إصدار جديد من حزمة SDK (الإصدار 2.0.0 أو إصدار أحدث من Python، والإصدار 2.0.0 أو إصدار أحدث من JavaScript). يمكنك الترقية للحصول على المخطط الجديد تلقائيًا. أضِف العنوان 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_modalities=["audio"] بإدخال {"type": "audio"} في response_format. الاطّلاع على أمثلة
  • (متعدد الوسائط) تحويل response_format من عنصر واحد إلى مصفوفة عند طلب وسائط إخراج متعددة