v1beta Interactions API ব্রেকিং পরিবর্তন নিয়ে আসছে যা API-এর আকারকে পুনর্গঠন করে
মিড-ফ্লাইট স্টিয়ারিং এবং অ্যাসিঙ্ক্রোনাস টুল কলের মতো ভবিষ্যতের ক্ষমতাকে
সমর্থন করে। এই পৃষ্ঠায় কী কী পরিবর্তন হচ্ছে তা ব্যাখ্যা করা হয়েছে এবং
মাইগ্রেট করার ব্যাপারে আপনাকে সাহায্য করতে আগে ও পরের কোডের উদাহরণ দেওয়া হয়েছে। পরিবর্তনের দুটি বিভাগ
রয়েছে:
- ধাপের স্কিমা:
একটি নতুন
stepsঅ্যারেoutputsঅ্যারেকে প্রতিস্থাপন করে, প্রতিটি ইন্টার্যাকশন টার্নের একটি স্ট্রাকচার্ড টাইমলাইন প্রদান করে। - আউটপুট ফর্ম্যাট কনফিগারেশন:
একটি নতুন পলিমরফিক
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)
জাভাস্ক্রিপ্ট
// 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);
বিশ্রাম
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)
জাভাস্ক্রিপ্ট
// 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
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": "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}")
জাভাস্ক্রিপ্ট
// 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" }
}
]
}
পরে (নতুন স্কিমা)
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}")
জাভাস্ক্রিপ্ট
// 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" }
}
]
}
সার্ভার-সাইড টুল
সার্ভার-সাইড টুল (যেমন Google Search বা কোড এক্সিকিউশন) এখন steps অ্যারেতে নির্দিষ্ট
ধাপের ধরন প্রদান করে। পুরনো স্কিমা এইসব
অপারেশনকে outputs অ্যারের মধ্যে নির্দিষ্ট কন্টেন্টের ধরন হিসেবে রিটার্ন করলেও, নতুন স্কিমা
সেগুলিকে steps অ্যারের মধ্যে সরিয়ে দেয়। নিচে দেওয়া উদাহরণে Google Search ব্যবহার করা হয়েছে।
আগে (পুরনো)
Python
# Accessing search results in legacy schema
for output in interaction.outputs:
if output.type == "google_search_call":
print(f"Searched for: {output.arguments.queries}")
elif output.type == "google_search_result":
print(f"Found results: {output.result.rendered_content}")
জাভাস্ক্রিপ্ট
// 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.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}")
জাভাস্ক্রিপ্ট
// 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}`);
}
}
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": "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.createdinteraction.completedinteraction.in_progressinteraction.requires_actionstep.startstep.deltastep.stop
বাতিল করা ইভেন্টের ধরন
উপরে তালিকাভুক্ত নতুন ইভেন্টগুলি নিম্নলিখিত লিগ্যাসি ইভেন্টের ধরনকে প্রতিস্থাপন করে:
interaction.start→interaction.createdcontent.start→step.startcontent.delta→step.deltacontent.stop→step.stopinteraction.complete→interaction.completedinteraction.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)
জাভাস্ক্রিপ্ট
// 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);
}
}
}
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": "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="")
জাভাস্ক্রিপ্ট
// 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);
}
}
}
বিশ্রাম
# 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টি পরিবর্তন
আপডেট করা API সব আউটপুট ফর্ম্যাট কন্ট্রোলকে একটি ইউনিফায়েড,
পলিমরফিক response_format ফিল্ডে একত্রিত করে। এটি আউটপুট কনফিগারেশনকে সবচেয়ে
উচ্চ লেভেলে সেন্ট্রালাইজ করে এবং generation_config মডেলের আচরণ (যেমন
টেম্পারেচার, top_p ও থিঙ্কিং) সংক্রান্ত বিষয়গুলিতে ফোকাস করে।
গুরুত্বপূর্ণ পরিবর্তন
- API
response_mime_typeসরিয়ে দেয়। আপনি এখনresponse_format-এর মধ্যে প্রতিটি ফর্ম্যাট এন্ট্রির জন্য MIME-এর ধরন নির্দিষ্ট করেন। response_formatএখন একটি পলিমরফিক অবজেক্ট (বা অ্যারে)। প্রতিটি এন্ট্রিতে একটিtypeডিসক্রিমিনেটর (text,audio,image) এবং টাইপ-নির্দিষ্ট ফিল্ড থাকে। একাধিক আউটপুট মোডালিটির অনুরোধ করতে, ফর্ম্যাট এন্ট্রির একটি অ্যারে পাস করুন।image_config,generation_configথেকেresponse_format-এ সরে যায়। আপনি এখন"type": "image"সহresponse_formatএন্ট্রিতেaspect_ratioএবংimage_size-এর মতো ইমেজ আউটপুট সেটিংস নির্দিষ্ট করতে পারবেন।
স্ট্রাকচার্ড আউটপুট (JSON)
নতুন স্কিমা response_mime_type ফিল্ড সরিয়ে দেয়। পরিবর্তে, "type": "text" সহ response_format অবজেক্টের মধ্যে MIME-এর ধরন এবং JSON স্কিমা উল্লেখ করুন।
আগে (পুরনো)
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)
জাভাস্ক্রিপ্ট
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);
বিশ্রাম
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)
জাভাস্ক্রিপ্ট
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" }
}
}
}
}'
ছবির কনফিগারেশন
নতুন স্কিমা generation_config থেকে image_config সরিয়ে দেয়। আপনি এখন "type": "image" সহ response_format এন্ট্রিতে
ইমেজ আউটপুট সেটিংস নির্দিষ্ট করেন।
আগে (পুরনো)
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"
}
},
)
জাভাস্ক্রিপ্ট
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'
}
},
});
বিশ্রাম
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"
},
)
জাভাস্ক্রিপ্ট
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"]-এর পরিবর্তে "type": "audio"-এর response_format এন্ট্রি ব্যবহার করে।
আগে (পুরনো)
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"}
]
}
)
জাভাস্ক্রিপ্ট
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' }
]
},
});
বিশ্রাম
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"}
]
}
)
জাভাস্ক্রিপ্ট
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-এ ফর্ম্যাট এন্ট্রিগুলির একটি অ্যারে
পাস করুন।
নতুন স্কিমায় কীভাবে মাইগ্রেট করবেন
SDK ব্যবহারকারী
লেটেস্ট SDK ভার্সনে (Python ≥২.০.০, JavaScript ≥২.০.০) আপগ্রেড করুন। SDK আপনাকে অটোমেটিক নতুন স্কিমায় অপ্ট-ইন করে দেয় — আপনাকে শুধু উত্তর পড়ার পদ্ধতি আপডেট করতে হবে (উপরে উদাহরণ দেখুন), এর বাইরে আর কোনও কোড পরিবর্তন করতে হবে না। মনে রাখবেন, এইসব SDK ভার্সনে শুধুমাত্র নতুন স্কিমা কাজ করে। পুরনো SDK ভার্সন (Python 1.x.x, JavaScript 1.x.x) ৮ জুন, ২০২৬-এ লিগ্যাসি স্কিমা সরিয়ে না দেওয়া পর্যন্ত কাজ করা চালিয়ে যাবে।
REST API ব্যবহারকারী
নতুন স্কিমায় এখনই অপ্ট-ইন করতে আপনার অনুরোধে Api-Revision: 2026-05-20 হেডার যোগ করুন।
২৬ মে-এর পরে, নতুন স্কিমা সব অনুরোধের জন্য ডিফল্ট
হয়ে যাবে। আপনি Api-Revision: 2026-05-07
৮ জুন পর্যন্ত সাময়িকভাবে অপ্ট-আউট করতে পারবেন, এই তারিখের পরে API স্থায়ীভাবে পুরনো স্কিমা সরিয়ে দেবে।
টাইমলাইন
| তারিখ | ধাপ | SDK ব্যবহারকারী | REST API ব্যবহারকারী |
|---|---|---|---|
| ৭ মে | অপ্ট-ইন করুন | নতুন SDK ভার্সন উপলভ্য (Python ≥২.০.০, JS ≥২.০.০)। অটোমেটিক নতুন স্কিমা পেতে আপগ্রেড করুন। | চালু করতে Api-Revision: 2026-05-20 হেডার যোগ করুন। ডিফল্ট হিসেবে লিগ্যাসিই থেকে যায়। |
| মে ২৬ | ডিফল্ট ফ্লিপ | আগে থেকেই আপগ্রেড করা থাকলে কোনও অ্যাকশন নিতে হবে না। পুরনো SDK (Python 1.x.x, JS 1.x.x) এখনও কাজ করে তবে পুরনো উত্তর দেয়। | নতুন স্কিমা এখন ডিফল্ট হিসেবে সেট করা হয়েছে। বেরিয়ে আসতে Api-Revision: 2026-05-07 হেডার পাঠান। |
| ৮ জুন | সানসেট | Python 1.x.x এবং JS 1.x.x SDK ভার্সন ইন্ট্যার্যাকশন API কলের ক্ষেত্রে কাজ করবে না। | Interactions API-এর জন্য পুরনো স্কিমা সরিয়ে দেওয়া হয়েছে। Api-Revision হেডার উপেক্ষা করা হয়েছে। |
মাইগ্রেশন চেকলিস্ট
ধাপের স্কিমা (steps)
outputs-এর পরিবর্তেstepsঅ্যারে থেকে উত্তর কন্টেন্ট পড়তে কোড আপডেট করুন। উদাহরণ দেখুন।- আপনার কোড
user_inputএবংmodel_outputদুই ধরনের ধাপই ম্যানেজ করে কিনা তা যাচাই করুন। উদাহরণ দেখুন। - (ফাংশন কলিং)
stepsঅ্যারেতেfunction_callধাপ খুঁজে পেতে কোড আপডেট করুন। উদাহরণ দেখুন। - (সার্ভার-সাইড টুল) টুল-নির্দিষ্ট ধাপ (যেমন,
google_search_call,google_search_result) হ্যান্ডেল করার জন্য কোড আপডেট করুন। উদাহরণ দেখুন। - (স্টেটলেস ইতিহাস) পরবর্তী অনুরোধের
inputফিল্ডেstepsঅ্যারে পাস করার জন্য ইতিহাস ম্যানেজমেন্ট আপডেট করুন। বিবরণ দেখুন। - (শুধুমাত্র স্ট্রিমিং) নতুন SSE ইভেন্টের ধরন (
interaction.created,step.delta, ইত্যাদি) শোনার জন্য ক্লায়েন্ট আপডেট করুন। উদাহরণ দেখুন।
আউটপুট ফর্ম্যাট কনফিগারেশন (response_format)
response_format-এর মধ্যেresponse_mime_type-এর জায়গায়mime_typeফিল্ড ব্যবহার করুন। উদাহরণ দেখুন।- আপনার আগে থেকে থাকা
response_formatJSON স্কিমা{"type": "text", "schema": ...}অবজেক্টের মধ্যে র্যাপ করুন। উদাহরণ দেখুন। - (Image Generation) Move
image_configfromgeneration_configto a{"type": "image", ...}entry inresponse_format. উদাহরণ দেখুন। - (স্পিচ জেনারেশন)
response_format-এresponse_modalities=["audio"]-এর পরিবর্তে{"type": "audio"}এন্ট্রি করুন। উদাহরণ দেখুন। - (মাল্টিমোডাল) একাধিক আউটপুট মোডালিটির অনুরোধ করার সময়
response_format-কে একটি অবজেক্ট থেকে অ্যারেতে কনভার্ট করুন।