URL কন্টেক্সট

URL কন্টেক্সট টুল আপনাকে URL-এর আকারে মডেলগুলিতে অতিরিক্ত কন্টেক্সট প্রদান করতে দেয়। আপনার অনুরোধে URL অন্তর্ভুক্ত করার মাধ্যমে, মডেলটি সেই পৃষ্ঠাগুলি থেকে কন্টেন্ট অ্যাক্সেস করবে (যতক্ষণ না এটি সীমাবদ্ধতা বিভাগে তালিকাভুক্ত URL প্রকার হয়) যাতে এর উত্তর সম্পর্কে তথ্য প্রদান এবং উন্নত করা যায়।

URL কন্টেক্সট টুল নিম্নলিখিত টাস্কের জন্য উপযোগী:

  • ডেটা এক্সট্র্যাক্ট করা: একাধিক URL থেকে দাম, নাম বা মূল ফলাফলের মতো নির্দিষ্ট তথ্য সংগ্রহ করা।
  • ডকুমেন্ট তুলনা করা: পার্থক্য শনাক্ত করতে এবং ট্রেন্ড ট্র্যাক করতে একাধিক রিপোর্ট, নিবন্ধ বা PDF বিশ্লেষণ করুন।
  • কন্টেন্ট একত্রিত ও তৈরি করা: সঠিক সারসংক্ষেপ, ব্লগ পোস্ট বা রিপোর্ট তৈরি করতে একাধিক সোর্স URL থেকে তথ্য একত্রিত করা।
  • কোড ও ডকুমেন্ট বিশ্লেষণ করা: কোড ব্যাখ্যা করতে, সেট-আপ সংক্রান্ত নির্দেশাবলী তৈরি করতে বা প্রশ্নের উত্তর দিতে, GitHub রিপোজিটরি বা টেকনিক্যাল ডকুমেন্টেশন উল্লেখ করুন।

দুটি আলাদা ওয়েবসাইট থেকে দুটি রেসিপি কীভাবে তুলনা করতে হয় তা নিম্নলিখিত উদাহরণ থেকে দেখুন।

Python

# This will only work for SDK newer than 2.0.0
from google import genai

client = genai.Client()

url1 = "https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"
url2 = "https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/"

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input=f"Compare the ingredients and cooking times from the recipes at {url1} and {url2}",
    tools=[{"type": "url_context"}]
)

# Print the model's text response and its source annotations
for step in interaction.steps:
    if step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "text":
                print(content_block.text)
                if content_block.annotations:
                    print("\nSources:")
                    for annotation in content_block.annotations:
                        if annotation.type == "url_citation":
                            print(f"  - {annotation.title}: {annotation.url}")

Javascript

// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const interaction = await client.interactions.create({
    model: "gemini-3.8-flash",
    input: "Compare the ingredients and cooking times from the recipes at https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592 and https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/",
    tools: [{ type: "url_context" }]
  });

  // Print the model's text response and its source annotations
  for (const step of interaction.steps) {
    if (step.type === 'model_output') {
      for (const contentBlock of step.content) {
        if (contentBlock.type === 'text') {
          console.log(contentBlock.text);
          if (contentBlock.annotations) {
            console.log("\nSources:");
            for (const annotation of contentBlock.annotations) {
              if (annotation.type === 'url_citation') {
                console.log(`  - ${annotation.title}: ${annotation.url}`);
              }
            }
          }
        }
      }
    }
  }
}

await main();

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    url1 := "https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592"
    url2 := "https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/"

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-flash"),
            Input: interactions.NewInteractionsInput(
                fmt.Sprintf("Compare the ingredients and cooking times from the recipes at %s and %s", url1, url2),
            ),
            Tools: []interactions.Tool{
                interactions.NewTool(interactions.URLContext{}),
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    // Print the model's text response and its source annotations
    for _, step := range res.Interaction.Steps {
        if step.ModelOutputStep != nil {
            for _, contentBlock := range step.ModelOutputStep.Content {
                if contentBlock.TextContent != nil {
                    fmt.Println(contentBlock.TextContent.Text)
                    if len(contentBlock.TextContent.Annotations) > 0 {
                        fmt.Println("\nSources:")
                        for _, annotation := range contentBlock.TextContent.Annotations {
                            if annotation.URLCitation != nil {
                                fmt.Printf("  - %s: %s\n", annotation.URLCitation.GetTitle(), annotation.URLCitation.GetURL())
                            }
                        }
                    }
                }
            }
        }
    }
}

REST

# Specifies the API revision to avoid breaking changes when they become default
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.8-flash",
      "input": "Compare the ingredients and cooking times from the recipes at https://www.foodnetwork.com/recipes/ina-garten/perfect-roast-chicken-recipe-1940592 and https://www.allrecipes.com/recipe/21151/simple-whole-roast-chicken/",
      "tools": [{"type": "url_context"}]
  }'

এটি কীভাবে কাজ করে

URL কন্টেক্সট টুল, স্পিড, খরচ ও ফ্রেশ ডেটা অ্যাক্সেস করার মধ্যে ব্যালেন্স বজায় রাখতে, দুটি ধাপের রিট্রিভাল প্রসেস ব্যবহার করে। আপনি কোনও URL দিলে, টুলটি প্রথমে ইন্টার্নাল ইন্ডেক্স ক্যাশে থেকে কন্টেন্ট ফেচ করার চেষ্টা করে। এটি খুবই অপ্টিমাইজ করা ক্যাশে হিসেবে কাজ করে। কোনও URL ইন্ডেক্সে উপলভ্য না থাকলে (যেমন, এটি খুব নতুন পৃষ্ঠা হলে), টুলটি অটোমেটিক লাইভ ফেচ করার বিকল্পে চলে যায়। এটি রিয়েল-টাইমে কন্টেন্ট ফিরিয়ে আনার জন্য সরাসরি URL অ্যাক্সেস করে।

আরও শক্তিশালী ওয়ার্কফ্লো তৈরি করতে, আপনি URL প্রসঙ্গ টুলকে অন্যান্য টুলের সাথে একত্রিত করতে পারেন।

Gemini 3 মডেল কাস্টম টুলের (ফাংশন কলিং) সাথে বিল্ট-ইন টুল (যেমন URL কন্টেক্সট) একত্রিত করার সুবিধা প্রদান করে। টুল কম্বিনেশন পৃষ্ঠা থেকে আরও জানুন।

URL প্রসঙ্গ ও Google Search-এর মাধ্যমে গ্রাউন্ডিং, দু'টিই চালু করা থাকলে, মডেলটি অনলাইনে প্রাসঙ্গিক তথ্য খুঁজে পেতে সার্চ করার ক্ষমতা ব্যবহার করতে পারে এবং তারপরে, এটি যে পৃষ্ঠাগুলি খুঁজে পায় সেগুলির আরও গভীরভাবে বোঝার জন্য URL প্রসঙ্গ টুল ব্যবহার করতে পারে। এই পদ্ধতিটি সেইসব প্রম্পটের জন্য খুব উপযোগী যেগুলির জন্য নির্দিষ্ট পৃষ্ঠা সম্পর্কে বিস্তারিত সার্চ ও গভীর বিশ্লেষণ, দুটিই প্রয়োজন।

Python

# This will only work for SDK newer than 2.0.0
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input="Give me three day events schedule based on YOUR_URL. Also let me know what needs to taken care of considering weather and commute.",
    tools=[
        {"type": "url_context"},
        {"type": "google_search"}
    ]
)

for step in interaction.steps:
    if step.type == "model_output":
        for content_block in step.content:
            if content_block.type == "text":
                print(content_block.text)

Javascript

// This will only work for SDK newer than 2.0.0
import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const interaction = await client.interactions.create({
    model: "gemini-3.8-flash",
    input: "Give me three day events schedule based on YOUR_URL. Also let me know what needs to taken care of considering weather and commute.",
    tools: [
      { type: "url_context" },
      { type: "google_search" }
    ]
  });

  for (const step of interaction.steps) {
    if (step.type === 'model_output') {
      for (const contentBlock of step.content) {
        if (contentBlock.type === 'text') console.log(contentBlock.text);
      }
    }
  }
}

await main();

খুলুন

package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-flash"),
            Input: interactions.NewInteractionsInput("Give me three day events schedule based on YOUR_URL. Also let me know what needs to taken care of considering weather and commute."),
            Tools: []interactions.Tool{
                interactions.NewTool(interactions.URLContext{}),
                interactions.NewTool(interactions.GoogleSearch{}),
            },
        }),
    })
    if err != nil {
        log.Fatal(err)
    }

    for _, step := range res.Interaction.Steps {
        if step.ModelOutputStep != nil {
            for _, contentBlock := range step.ModelOutputStep.Content {
                if contentBlock.TextContent != nil {
                    fmt.Println(contentBlock.TextContent.Text)
                }
            }
        }
    }
}

বিশ্রাম

# Specifies the API revision to avoid breaking changes when they become default
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.8-flash",
      "input": "Give me three day events schedule based on YOUR_URL. Also let me know what needs to taken care of considering weather and commute.",
      "tools": [
          {"type": "url_context"},
          {"type": "google_search"}
      ]
  }'

উত্তর বোঝা

মডেল যখন URL কন্টেক্সট টুল ব্যবহার করে, তখন তার টেক্সট উত্তরে টেক্সট কন্টেন্ট ব্লকে ইনলাইন url_citation অ্যানোটেশন অন্তর্ভুক্ত থাকে। প্রতিটি অ্যানোটেশন উত্তরের টেক্সটের একটি অংশকে (start_index এবং end_index-এর মাধ্যমে) সোর্স URL-এর সাথে লিঙ্ক করে যেখান থেকে এটি নেওয়া হয়েছে। আপনার অ্যাপ্লিকেশনে উদ্ধৃতি দেখানোর এটিই প্রাথমিক উপায় — কীভাবে সেগুলি এক্সট্র্যাক্ট করতে হয় তা জানতে উপরে প্রধান উদাহরণ দেখুন।

উত্তরে প্রতিটি URL থেকে তথ্য সংগ্রহের চেষ্টা (স্ট্যাটাস, তথ্য সংগ্রহ করা হয়েছে এমন URL) সম্পর্কে মেটাডেটা সহ url_context_result ধাপও অন্তর্ভুক্ত থাকে। এটি মূলত ডিবাগিংয়ের জন্য উপযোগী।

নিরাপত্তা সংক্রান্ত পরীক্ষা

সিস্টেম URL-এ কন্টেন্ট মডারেশন চেক করে যাতে কনফার্ম করা যায় যে সেগুলি নিরাপত্তা সংক্রান্ত স্ট্যান্ডার্ড মেনে চলছে। কোনও URL এই চেক পাস করতে না পারলে, সংশ্লিষ্ট url_context_result ধাপে "unsafe"-এর মধ্যে status দেখাবে।

টোকেন কাউন্ট

আপনার প্রম্পটে উল্লেখ করা URL থেকে পাওয়া কন্টেন্ট ইনপুট টোকেনের অংশ হিসেবে গণনা করা হয়। আপনি ইন্টার‍্যাকশনের usage অবজেক্টে টোকেন কাউন্ট দেখতে পাবেন। নিচে একটি উদাহরণ দেওয়া হল:

'usage': {
  'output_tokens': 45,
  'input_tokens': 27,
  'input_tokens_details': [{'modality': 'TEXT', 'token_count': 27}],
  'thoughts_tokens': 31,
  'tool_use_input_tokens': 10309,
  'tool_use_input_tokens_details': [{'modality': 'TEXT', 'token_count': 10309}],
  'total_tokens': 10412
}

টোকেন প্রতি দাম নির্ভর করে কোন মডেল ব্যবহার করা হয়েছে তার উপর, বিশদে জানতে দাম পৃষ্ঠা দেখুন।

যেসব মডেলে কাজ করে

মডেল URL কন্টেক্সট
Gemini 4 Argon ✔️
Gemini 3.8 Flash ✔️
Gemini 3.6 Flash ✔️
Gemini 3.5 Flash-Lite ✔️
Gemini 3.1 Pro প্রিভিউ ✔️
Gemini 3.1 Flash-Lite ✔️
Gemini 3 Flash প্রিভিউ ✔️
Gemini 2.5 Pro ✔️
Gemini 2.5 Flash ✔️
Gemini 2.5 Flash-Lite ✔️

পেশাদার পদ্ধতি

  • নির্দিষ্ট URL প্রদান করুন: সেরা ফলাফলের জন্য, আপনি মডেলকে যে কন্টেন্ট বিশ্লেষণ করাতে চান, সেটির সরাসরি URL প্রদান করুন। মডেলটি শুধুমাত্র আপনার প্রদান করা URL থেকে কন্টেন্ট ফিরিয়ে আনবে, নেস্টেড লিঙ্ক থেকে কোনও কন্টেন্ট নয়।
  • অ্যাক্সেসিবিলিটি চেক করুন: আপনার দেওয়া URL-এ ক্লিক করলে এমন কোনও পৃষ্ঠা খোলে কিনা তা যাচাই করুন যেখানে লগ-ইন করতে হয় বা যা পেওয়ালের পিছনে থাকে।
  • সম্পূর্ণ URL ব্যবহার করুন: প্রোটোকল সহ সম্পূর্ণ URL দিন (যেমন, শুধু google.com-এর পরিবর্তে https://www.google.com)।

সীমাবদ্ধতা

  • অনুরোধের সীমা: টুলটি প্রতিটি অনুরোধে সর্বাধিক ২০টি URL প্রসেস করতে পারে।
  • URL কন্টেন্টের সাইজ: একটি URL থেকে পাওয়া কন্টেন্টের সর্বাধিক সাইজ হল ৩৪ এমবি।
  • সর্বজনীন অ্যাক্সেসযোগ্যতা: URL-কে ওয়েবে সর্বজনীনভাবে অ্যাক্সেসযোগ্য হতে হবে। লোকালহোস্ট অ্যাড্রেস (যেমন, localhost, 127.0.0.1), ব্যক্তিগত নেটওয়ার্ক এবং টানেলিং পরিষেবা (যেমন, ngrok, pinggy) কাজ করে না।

কাজ করে ও কাজ করে না এমন কন্টেন্টের ধরন

টুলটি নিম্নলিখিত কন্টেন্টের ধরন সহ URL থেকে কন্টেন্ট এক্সট্র্যাক্ট করতে পারে:

  • টেক্সট (text/html, application/json, text/plain, text/xml, text/css, text/javascript , text/csv, text/rtf)
  • ছবি (image/png, image/jpeg, image/bmp, image/webp)
  • PDF (application/pdf)

নিম্নলিখিত কন্টেন্টের ধরন কাজ করে না:

  • পেওয়াল কন্টেন্ট
  • YouTube ভিডিও (YouTube URL কীভাবে প্রসেস করতে হয় তা জানতে ভিডিও বোঝা দেখুন )
  • Google Docs বা স্প্রেডশিটের মতো Google Workspace ফাইল
  • ভিডিও ও অডিও ফাইল