টেক্সট তৈরি

জেমিনি এপিআই টেক্সট, ছবি, ভিডিও এবং অডিও ইনপুট থেকে টেক্সট আউটপুট তৈরি করতে পারে।

এখানে একটি সাধারণ উদাহরণ দেওয়া হলো:

পাইথন

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="How does AI work?"
)
print(interaction.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "How does AI work?",
  });
  console.log(interaction.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "How does AI work?"
  }'

মিথুন রাশির সাথে চিন্তা

মিথুন রাশির জাতকদের মধ্যে প্রায়শই ডিফল্টরূপে 'চিন্তা' করার ক্ষমতা সক্রিয় থাকে, যা তাদের কোনো অনুরোধে সাড়া দেওয়ার আগে যুক্তি দিয়ে বিচার-বিবেচনা করার সুযোগ দেয়।

প্রতিটি মডেল বিভিন্ন থিঙ্কিং কনফিগারেশন সমর্থন করে, যা আপনাকে খরচ, ল্যাটেন্সি এবং ইন্টেলিজেন্সের উপর নিয়ন্ত্রণ দেয়। আরও বিস্তারিত জানতে, থিঙ্কিং গাইডটি দেখুন।

পাইথন

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="How does AI work?",
    generation_config={
        "thinking_level": "low"
    }
)
print(interaction.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "How does AI work?",
    generation_config: {
      thinking_level: "low",
    },
  });
  console.log(interaction.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "How does AI work?",
    "generation_config": {
      "thinking_level": "low"
    }
  }'

সিস্টেম নির্দেশাবলী এবং অন্যান্য কনফিগারেশন

আপনি সিস্টেম নির্দেশাবলীর মাধ্যমে জেমিনি মডেলের আচরণ নিয়ন্ত্রণ করতে পারেন। মডেলের আচরণ কনফিগার করতে একটি system_instruction প্যারামিটার পাস করুন।

পাইথন

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    system_instruction="You are a cat. Your name is Neko.",
    input="Hello there"
)

print(interaction.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "Hello there",
    system_instruction: "You are a cat. Your name is Neko.",
  });
  console.log(interaction.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "system_instruction": "You are a cat. Your name is Neko.",
    "input": "Hello there"
  }'

আপনি generation_config প্যারামিটার ব্যবহার করে তাপমাত্রার মতো ডিফল্ট জেনারেশন প্যারামিটারগুলোও ওভাররাইড করতে পারেন।

পাইথন

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Explain how AI works",
    generation_config={
        "temperature": 0.1
    }
)
print(interaction.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "Explain how AI works",
    generation_config: {
      temperature: 0.1,
    },
  });
  console.log(interaction.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Explain how AI works",
    "generation_config": {
      "temperature": 0.1
    }
  }'

কনফিগারযোগ্য প্যারামিটারসমূহের সম্পূর্ণ তালিকা এবং তাদের বিবরণের জন্য ইন্টারঅ্যাকশনস এপিআই রেফারেন্স দেখুন।

মাল্টিমোডাল ইনপুট

জেমিনি এপিআই মাল্টিমোডাল ইনপুট সমর্থন করে, যা আপনাকে টেক্সটের সাথে মিডিয়া ফাইল একত্রিত করার সুযোগ দেয়। নিম্নলিখিত উদাহরণটি একটি ছবি প্রদানের পদ্ধতি প্রদর্শন করে:

পাইথন

from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="path/to/organ.jpg")

interaction = client.interactions.create(
    model="gemini-3-flash-preview",
    input=[
        {"type": "text", "text": "Tell me about this instrument"},
        {
            "type": "image",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        }
    ]
)
print(interaction.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const uploadedFile = await ai.files.upload({
    file: "path/to/organ.jpg",
    config: { mimeType: "image/jpeg" }
  });

  const interaction = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: [
      {type: "text", text: "Tell me about this instrument"},
      {
        type: "image",
        uri: uploadedFile.uri,
        mimeType: uploadedFile.mimeType
      }
    ],
  });
  console.log(interaction.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

# First upload the file using the Files API, then use the URI:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": [
      {"type": "text", "text": "Tell me about this instrument"},
      {
        "type": "image",
        "uri": "YOUR_FILE_URI",
        "mime_type": "image/jpeg"
      }
    ]
  }'

ছবি প্রদানের বিকল্প পদ্ধতি এবং আরও উন্নত ইমেজ প্রসেসিংয়ের জন্য, আমাদের ইমেজ আন্ডারস্ট্যান্ডিং গাইডটি দেখুন। এই এপিআই ডকুমেন্ট , ভিডিও এবং অডিও ইনপুট ও তা বুঝতেও সহায়তা করে।

স্ট্রিমিং প্রতিক্রিয়া

ডিফল্টরূপে, সম্পূর্ণ জেনারেশন প্রক্রিয়াটি সম্পন্ন হওয়ার পরেই মডেলটি একটি প্রতিক্রিয়া ফেরত দেয়।

আরও সাবলীল ইন্টারঅ্যাকশনের জন্য, রেসপন্স চাঙ্কগুলো তৈরি হওয়ার সাথে সাথেই তা পরিচালনা করতে স্ট্রিমিং ব্যবহার করুন।

পাইথন

from google import genai

client = genai.Client()

stream = client.interactions.create(
    model="gemini-3-flash-preview",
    input="Explain how AI works",
    stream=True
)
for event in stream:
    if event.event_type == "step.delta":
        if event.delta.type == "text":
            print(event.delta.text, end="")

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const stream = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "Explain how AI works",
    stream: true,
  });

  for await (const event of stream) {
    if (event.type === "step.delta") {
      if (event.delta.type === "text") {
        process.stdout.write(event.delta.text);
      }
    }
  }
}

await main();

বিশ্রাম

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  --no-buffer \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "Explain how AI works",
    "stream": true
  }'

একাধিক পালা কথোপকথন

ইন্টারঅ্যাকশনস এপিআই previous_interaction_id ব্যবহার করে ইন্টারঅ্যাকশনগুলোকে একসাথে শৃঙ্খলিত করার মাধ্যমে একাধিক পালাবিশিষ্ট কথোপকথন সমর্থন করে। প্রতিটি পালা একটি পৃথক ইন্টারঅ্যাকশন, এবং এপিআই স্বয়ংক্রিয়ভাবে কথোপকথনের ইতিহাস পরিচালনা করে।

পাইথন

from google import genai

client = genai.Client()

interaction1 = client.interactions.create(
    model="gemini-3-flash-preview",
    input="I have 2 dogs in my house.",
)
print(interaction1.steps[-1].content[0].text)

interaction2 = client.interactions.create(
    model="gemini-3-flash-preview",
    input="How many paws are in my house?",
    previous_interaction_id=interaction1.id,
)
print(interaction2.steps[-1].content[0].text)

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction1 = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "I have 2 dogs in my house.",
  });
  console.log("Response 1:", interaction1.steps.at(-1).content[0].text);

  const interaction2 = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "How many paws are in my house?",
    previousInteractionId: interaction1.id,
  });
  console.log("Response 2:", interaction2.steps.at(-1).content[0].text);
}

await main();

বিশ্রাম

RESPONSE1=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "I have 2 dogs in my house."
  }')

INTERACTION_ID=$(echo "$RESPONSE1" | jq -r '.name')

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "I have two dogs in my house. How many paws are in my house?",
    "previous_interaction_id": "'$INTERACTION_ID'"
  }'

previous_interaction_id স্ট্রিমিং মেথডগুলোর সাথে যুক্ত করে একাধিক পালাবিশিষ্ট কথোপকথনের জন্যও স্ট্রিমিং ব্যবহার করা যেতে পারে।

পাইথন

from google import genai

client = genai.Client()

interaction1 = client.interactions.create(
    model="gemini-3-flash-preview",
    input="I have 2 dogs in my house.",
)
print(interaction1.steps[-1].content[0].text)

stream = client.interactions.create(
    model="gemini-3-flash-preview",
    input="How many paws are in my house?",
    previous_interaction_id=interaction1.id,
    stream=True
)
for event in stream:
    if event.event_type == "step.delta":
        if event.delta.type == "text":
            print(event.delta.text, end="")

জাভাস্ক্রিপ্ট

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

async function main() {
  const interaction1 = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "I have 2 dogs in my house.",
  });
  console.log("Response 1:", interaction1.steps.at(-1).content[0].text);

  const stream = await ai.interactions.create({
    model: "gemini-3-flash-preview",
    input: "How many paws are in my house?",
    previousInteractionId: interaction1.id,
    stream: true,
  });
  for await (const event of stream) {
    if (event.type === "step.delta") {
      if (event.delta.type === "text") {
        process.stdout.write(event.delta.text);
      }
    }
  }
}

await main();

বিশ্রাম

RESPONSE1=$(curl -s -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "I have 2 dogs in my house."
  }')
INTERACTION_ID=$(echo "$RESPONSE1" | jq -r '.name')

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  --no-buffer \
  -d '{
    "model": "gemini-3-flash-preview",
    "input": "How many paws are in my house?",
    "previous_interaction_id": "'$INTERACTION_ID'",
    "stream": true
  }'

প্রম্পটিং টিপস

জেমিনি থেকে সর্বোত্তম সুবিধা পাওয়ার পরামর্শের জন্য আমাদের দ্রুত প্রকৌশল নির্দেশিকাটি দেখুন।

এরপর কী?