টিউটোরিয়াল: Gemini API দিয়ে শুরু করুন


Ai.google.dev এ দেখুন Google Colab-এ চালান GitHub-এ উৎস দেখুন

আপনি যদি দ্রুত জেমিনি এপিআই চেষ্টা করে দেখতে চান তবে আপনি REST এপিআইতে পদ্ধতিগুলি কল করতে curl কমান্ডগুলি ব্যবহার করতে পারেন। এই টিউটোরিয়াল শোয়ের উদাহরণগুলি প্রতিটি এপিআই পদ্ধতির জন্য কল করে।

কোল্যাব পরিবেশের পরিবর্তনশীল সেট করতে এবং একটি চিত্র প্রদর্শন করতে পাইথন কোড ব্যবহার করে তবে REST এপিআইয়ের সাথে কাজ করার জন্য আপনার কোলাবের দরকার নেই। আপনি পরবর্তী বিভাগে বর্ণিত হিসাবে API_KEY সেট থাকলে আপনি সংশোধন ছাড়াই কল্যাবের বাইরে সমস্ত curl উদাহরণ চালাতে সক্ষম হবেন।

প্রতিটি curl কমান্ডের জন্য আপনাকে অবশ্যই প্রযোজ্য মডেলের নাম এবং আপনার এপিআই কী নির্দিষ্ট করতে হবে।

আপনার এপিআই কী সেট আপ করুন

জেমিনি এপিআই ব্যবহার করতে আপনার একটি এপিআই কী দরকার। আপনার যদি ইতিমধ্যে একটি না থাকে তবে গুগল এআই স্টুডিওতে একটি কী তৈরি করুন।

একটি API কী পান

কোল্যাব -এ, বাম প্যানেলে "🔑" এর অধীনে সিক্রেটস ম্যানেজারের কীটি যুক্ত করুন। এটি GOOGLE_API_KEY নাম দিন। তারপরে আপনি এটি আপনার কার্ল কলের কীটি পাস করার জন্য পরিবেশের পরিবর্তনশীল হিসাবে যুক্ত করতে পারেন।

একটি টার্মিনালে, আপনি কেবল GOOGLE_API_KEY="Your API Key" চালাতে পারেন।

import os
from google.colab import userdata

os.environ['GOOGLE_API_KEY'] = userdata.get('GOOGLE_API_KEY')

মিথুন এবং Content ভিত্তিক এপিআই

পাঠ্য-কেবল ইনপুট

একটি ইনপুট বার্তা দেওয়া মডেল থেকে প্রতিক্রিয়া তৈরি করতে generateContent পদ্ধতিটি ব্যবহার করুন। যদি ইনপুটটিতে কেবল পাঠ্য থাকে তবে একটি মিথুন 1.5 মডেল বা জেমিনি 1.0 প্রো মডেল ব্যবহার করুন।

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts":[{
          "text": "Write a story about a magic backpack."}]}]}' 2> /dev/null
{
  "candidates": [
    {
      "content": {
        "parts": [
          {
            "text": "In the quaint town of Willow Creek, nestled amidst rolling hills and whispering willows, there lived an ordinary boy named Ethan. Ethan's life took an extraordinary turn the day he stumbled upon an enigmatic backpack hidden in the depths of his attic.\n\nCuriosity ignited within Ethan as he lifted the worn leather straps and unzipped its mysterious contents. Inside lay a shimmering array of vibrant objects and peculiar trinkets. There was a glowing orb that pulsated with an ethereal glow, a feather that seemed to have a life of its own, and a small, enigmatic key.\n\nAs Ethan explored each item, he realized they possessed astonishing abilities. The orb illuminated his path, casting a warm glow in the darkest of nights. The feather granted him the power of flight, allowing him to soar through the skies with newfound freedom. And the key opened a portal to a hidden world, a realm of endless wonder.\n\nArmed with his magical backpack, Ethan embarked on countless adventures. He flew over the towering mountains of Willow Creek, exploring their hidden secrets. He navigated the treacherous depths of the Enchanted Forest, where he encountered mythical creatures and ancient spirits. And he ventured into distant, unknown lands, uncovering lost civilizations and forgotten treasures.\n\nWith each adventure, Ethan's knowledge and abilities grew. He learned to harness the power of his backpack wisely, using its magic to help others and protect the world from evil forces. The backpack became an extension of himself, a symbol of hope and wonder in the face of adversity.\n\nAs the years went by, Ethan's reputation as the boy with the magic backpack spread far and wide. People from all walks of life came to him, seeking his guidance and protection. And Ethan never hesitated to lend a helping hand, using his extraordinary abilities to make the world a better place.\n\nIn the end, the magic backpack became more than just a collection of objects. It was a representation of Ethan's unwavering spirit, his boundless imagination, and his unwavering belief in the power of dreams. And as long as Ethan carried it with him, the magic of Willow Creek would live on, illuminating the darkest corners of the world with hope, wonder, and the limitless possibilities that resided within the heart of a child."
          }
        ],
        "role": "model"
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": [
        {
          "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HATE_SPEECH",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_HARASSMENT",
          "probability": "NEGLIGIBLE"
        },
        {
          "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
          "probability": "NEGLIGIBLE"
        }
      ]
    }
  ],
  "promptFeedback": {
    "safetyRatings": [
      {
        "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
        "probability": "NEGLIGIBLE"
      },
      {
        "category": "HARM_CATEGORY_HATE_SPEECH",
        "probability": "NEGLIGIBLE"
      },
      {
        "category": "HARM_CATEGORY_HARASSMENT",
        "probability": "NEGLIGIBLE"
      },
      {
        "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
        "probability": "NEGLIGIBLE"
      }
    ]
  }
}

পাঠ্য এবং চিত্র ইনপুট

জেমিনি বিভিন্ন মডেল সরবরাহ করে যা মাল্টিমোডাল ইনপুট (জেমিনি 1.5 মডেল এবং জেমিনি 1.0 প্রো ভিশন) পরিচালনা করতে পারে যাতে আপনি পাঠ্য এবং চিত্র উভয়ই ইনপুট করতে পারেন। প্রম্পটগুলির জন্য চিত্রের প্রয়োজনীয়তাগুলি পর্যালোচনা করার বিষয়টি নিশ্চিত করুন।

যখন প্রম্পট ইনপুটটিতে পাঠ্য এবং চিত্র উভয়ই অন্তর্ভুক্ত থাকে, তখন একটি জেমিনি 1.5 মডেল বা জেমিনি 1.0 প্রো ভিশন মডেল ব্যবহার করুন।

নিম্নলিখিত স্নিপেটগুলি আপনাকে একটি অনুরোধ তৈরি করতে এবং এটি রেস্ট এপিআইতে প্রেরণে সহায়তা করে।

curl -o image.jpg https://storage.googleapis.com/generativeai-downloads/images/scones.jpg
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  385k  100  385k    0     0  2053k      0 --:--:-- --:--:-- --:--:-- 2050k
import PIL.Image

img = PIL.Image.open("image.jpg")
img.resize((512, int(img.height*512/img.width)))

png

echo '{
  "contents":[
    {
      "parts":[
        {"text": "What is this picture?"},
        {
          "inline_data": {
            "mime_type":"image/jpeg",
            "data": "'$(base64 -w0 image.jpg)'"
          }
        }
      ]
    }
  ]
}' > request.json
curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=${GOOGLE_API_KEY} \
        -H 'Content-Type: application/json' \
        -d @request.json 2> /dev/null | grep "text"
"text": " The picture shows a table with a white tablecloth. On the table are two cups of coffee, a bowl of blueberries, and a plate of scones. There are also some flowers on the table."

মাল্টি-টার্ন কথোপকথন (চ্যাট)

জেমিনি ব্যবহার করে আপনি একাধিক টার্ন জুড়ে ফ্রিফর্ম কথোপকথন তৈরি করতে পারেন।

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [
        {"role":"user",
         "parts":[{
           "text": "Write the first line of a story about a magic backpack."}]},
        {"role": "model",
         "parts":[{
           "text": "In the bustling city of Meadow brook, lived a young girl named Sophie. She was a bright and curious soul with an imaginative mind."}]},
        {"role": "user",
         "parts":[{
           "text": "Can you set it in a quiet village in 1600s France?"}]},
      ]
    }' 2> /dev/null | grep "text"
"text": "In the quaint village of Fleur-de-Lys, nestled amidst the rolling hills of 17th century France, lived a young maiden named Antoinette. She possessed a heart brimming with curiosity and a spirit as vibrant as the wildflowers that bloomed in the meadows.\n\nOne sunny morn, as Antoinette strolled through the cobblestone streets, her gaze fell upon a peculiar sight—a weathered leather backpack resting atop a mossy stone bench. Intrigued, she cautiously approached the bag, her fingers tracing the intricate carvings etched into its surface. As her fingertips grazed the worn leather, a surge of warmth coursed through her body, and the backpack began to emit a soft, ethereal glow."

কনফিগারেশন

আপনি মডেলটিতে প্রেরণ করা প্রতিটি প্রম্পটে প্যারামিটার মানগুলি অন্তর্ভুক্ত করে যা মডেল কীভাবে প্রতিক্রিয়া তৈরি করে তা নিয়ন্ত্রণ করে। মডেলটি বিভিন্ন প্যারামিটার মানগুলির জন্য বিভিন্ন ফলাফল তৈরি করতে পারে। মডেল পরামিতি সম্পর্কে আরও জানুন।

এছাড়াও, আপনি যে প্রতিক্রিয়াগুলি ক্ষতিকারক হিসাবে বিবেচিত হতে পারে তার সম্ভাবনাগুলি সামঞ্জস্য করতে আপনি সুরক্ষা সেটিংস ব্যবহার করতে পারেন। ডিফল্টরূপে, সুরক্ষা সেটিংস সমস্ত মাত্রায় অনিরাপদ সামগ্রী হওয়ার মাঝারি এবং/অথবা উচ্চ সম্ভাবনা সহ সামগ্রীগুলি ব্লক করে। সুরক্ষা সেটিংস সম্পর্কে আরও জানুন।

নিম্নলিখিত উদাহরণটি generateContent পদ্ধতির সমস্ত পরামিতিগুলির জন্য মানগুলি নির্দিষ্ট করে।

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
        "contents": [{
            "parts":[
                {"text": "Write a story about a magic backpack."}
            ]
        }],
        "safetySettings": [
            {
                "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
                "threshold": "BLOCK_ONLY_HIGH"
            }
        ],
        "generationConfig": {
            "stopSequences": [
                "Title"
            ],
            "temperature": 1.0,
            "maxOutputTokens": 800,
            "topP": 0.8,
            "topK": 10
        }
    }'  2> /dev/null | grep "text"
"text": "Once upon a time, in a small town nestled at the foot of a majestic mountain range, lived a young girl named Lily. Lily was a bright and curious child who loved to explore the world around her. One day, while playing in the forest near her home, she stumbled upon a hidden cave. Intrigued, she stepped inside, and to her amazement, she discovered a dusty old backpack lying in a corner.\n\nCuriosity piqued, Lily reached out and picked up the backpack. As soon as her fingers brushed against the worn leather, she felt a strange tingling sensation coursing through her body. Suddenly, the backpack began to glow, emitting a soft, ethereal light that filled the cave.\n\nWith wide-eyed wonder, Lily opened the backpack to find it filled with an assortment of magical objects. There was a compass that always pointed to the nearest adventure, a magnifying glass that could reveal hidden secrets, a telescope that allowed her to see distant lands, and a book that contained the knowledge of the universe.\n\nOverjoyed with her discovery, Lily took the magic backpack home and began using its contents to explore the world in ways she had never imagined. She followed the compass to discover hidden treasures, used the magnifying glass to uncover the secrets of nature, gazed through the telescope to witness the wonders of the cosmos, and delved into the book to learn about the mysteries of the universe.\n\nAs Lily's adventures continued, she realized that the magic backpack was more than just a collection of enchanted items. It was a symbol of her own limitless potential and the power of her imagination. It taught her that with curiosity, courage, and a touch of magic, anything was possible.\n\nNews of Lily's magical backpack spread throughout the town, and soon, children from all around came to her, eager to learn about its wonders. Lily welcomed them with open arms, sharing her stories and inspiring them to embark on their own adventures.\n\nAnd so, the magic backpack became a beacon of hope and wonder, reminding everyone that the world is full of hidden treasures waiting to be discovered, if only one has the courage to step into the unknown."

স্ট্রিম জেনারেট সামগ্রী

generateContent পদ্ধতিটি পুরো প্রজন্মের প্রক্রিয়াটি শেষ করার পরে একটি প্রতিক্রিয়া প্রদান করে। আপনি পুরো ফলাফলের জন্য অপেক্ষা না করে দ্রুত ইন্টারঅ্যাকশনগুলি অর্জন করতে পারেন এবং পরিবর্তে আংশিক ফলাফলগুলি ফিরিয়ে দিতে streamGenerateContent ব্যবহার করতে পারেন।

!curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:streamGenerateContent?alt=sse&key=${GOOGLE_API_KEY}" \
        -H 'Content-Type: application/json' \
        --no-buffer \
        -d '{ "contents":[{"parts":[{"text": "Write long a story about a magic backpack."}]}]}' \
        2> /dev/null
data: {"candidates": [{"content": {"parts": [{"text": "In the quaint little town of Willow Creek, nestled among rolling hills and whispering willows"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}],"promptFeedback": {"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]} }

data: {"candidates": [{"content": {"parts": [{"text": ", there existed an extraordinary backpack that possessed an astonishing secret. Its unassuming canvas exterior and worn leather straps held a hidden realm brimming with wonder and endless possibilities."}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}

data: {"candidates": [{"content": {"parts": [{"text": "\n\nYoung Oliver, a curious and imaginative boy, stumbled upon this magical backpack in the dusty attic of his grandmother's house. Intrigued by its enigmatic aura, he unzipped it cautiously, revealing a seemingly ordinary interior. But as his fingers brushed against the lining, an ethereal glow emanated from within.\n\n"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}

data: {"candidates": [{"content": {"parts": [{"text": "With a gasp of surprise, Oliver watched as the backpack transformed before his very eyes. Its fabric shimmered and flowed like liquid silver, morphing into a portal that connected him to a hidden dimension. Step by step, he ventured into this enchanted realm, his heart pounding with a mixture of trepidation and exhilaration.\n\nThe backpack's interior was a vast and wondrous labyrinth filled with towering bookshelves, bubbling potions, and ethereal artifacts. Each turn offered a new discovery: a self-playing piano, a talking mirror that whispered ancient wisdom, and a compass that pointed to the furthest reaches of the imagination.\n\nOliver soon realized"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}

data: {"candidates": [{"content": {"parts": [{"text": " that this backpack was no mere container but a sentient being, capable of aiding him in his quests and expanding his horizons. It granted him the gift of tongues, allowing him to speak with animals and creatures from distant lands. It gifted him a quill that wrote stories that danced off the page, bringing his wildest dreams to life.\n\nTogether, Oliver and the backpack embarked on extraordinary adventures. They soared through the skies on the back of a majestic griffon, traversed treacherous terrains with the aid of a shape-shifting fox, and solved mysteries that had long baffled the wisest minds in Willow Creek.\n\nAs the days turned into weeks, Oliver's imagination flourished beyond measure. He painted vibrant landscapes with words, composed symphonies that echoed through the hidden realm, and invented gadgets that defied the laws of physics. The backpack became an extension of his boundless creativity, nurturing his wonder and fueling his aspirations.\n\nNews of Oliver's extraordinary backpack spread throughout the town and beyond. People flocked from far and wide to witness its marvels. Scholars sought its wisdom, artists sought its inspiration, and children dreamed of experiencing its boundless adventures.\n\nHowever, not all who approached the backpack with pure intentions. One fateful day, a greedy sorcerer named Maldred attempted to seize its power for himself. But"}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}

data: {"candidates": [{"content": {"parts": [{"text": " the backpack, sensing his malevolent nature, resisted his grasp and summoned a legion of fantastical creatures to its defense.\n\nIn a fierce battle that shook the very fabric of the hidden realm, Oliver and the backpack allied with brave heroes and wise wizards to defeat Maldred and his wicked forces. The town of Willow Creek was forever grateful, and the backpack became a symbol of hope and imagination for all who knew of its existence.\n\nAs the years passed, Oliver grew into a wise and compassionate leader, using the magic backpack to spread joy, inspire creativity, and unlock the potential of those around him. The hidden realm within its depths became a sanctuary for dreamers, inventors, and anyone who dared to embrace the wonders of the unknown.\n\nAnd so, the tale of the magic backpack was passed down through generations, a timeless testament to the power of imagination and the boundless possibilities that lie when wonder and curiosity ignite the human spirit."}],"role": "model"},"finishReason": "STOP","index": 0,"safetyRatings": [{"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HATE_SPEECH","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_HARASSMENT","probability": "NEGLIGIBLE"},{"category": "HARM_CATEGORY_DANGEROUS_CONTENT","probability": "NEGLIGIBLE"}]}]}

টোকেন গণনা করুন

দীর্ঘ প্রম্পটগুলি ব্যবহার করার সময়, মডেলটিতে কোনও সামগ্রী প্রেরণের আগে টোকেনগুলি গণনা করা কার্যকর হতে পারে।

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:countTokens?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts":[{
          "text": "Write a story about a magic backpack."}]}]}' > response.json
% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   127    0    23  100   104    105    477 --:--:-- --:--:-- --:--:--   585
cat response.json
{
  "totalTokens": 8
}

এমবেডিং

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

embedding-001 মডেলটি embedContents বা batchEmbedContents সাথে ব্যবহার করুন:

curl https://generativelanguage.googleapis.com/v1beta/models/embedding-001:embedContent?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
        "model": "models/embedding-001",
        "content": {
        "parts":[{
          "text": "Write a story about a magic backpack."}]} }' 2> /dev/null | head
{
  "embedding": {
    "values": [
      0.008624583,
      -0.030451821,
      -0.042496547,
      -0.029230341,
      0.05486475,
      0.006694871,
      0.004025645,
curl https://generativelanguage.googleapis.com/v1beta/models/embedding-001:batchEmbedContents?key=$GOOGLE_API_KEY \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "requests": [{
        "model": "models/embedding-001",
        "content": {
        "parts":[{
          "text": "Write a story about a magic backpack."}]} }]}' 2> /dev/null | head
{
  "embeddings": [
    {
      "values": [
        0.008624583,
        -0.030451821,
        -0.042496547,
        -0.029230341,
        0.05486475,
        0.006694871,

মডেল তথ্য

মডেল পান

আপনি যদি কোনও মডেলের ইউআরএল GET তবে এপিআই সেই মডেল সম্পর্কে তথ্য যেমন সংস্করণ, ডিসপ্লে নাম, ইনপুট টোকেন সীমা ইত্যাদি সম্পর্কে তথ্য ফেরত get পদ্ধতি ব্যবহার করে

curl https://generativelanguage.googleapis.com/v1beta/models/gemini-pro?key=$GOOGLE_API_KEY
{
  "name": "models/gemini-pro",
  "version": "001",
  "displayName": "Gemini Pro",
  "description": "The best model for scaling across a wide range of tasks",
  "inputTokenLimit": 30720,
  "outputTokenLimit": 2048,
  "supportedGenerationMethods": [
    "generateContent",
    "countTokens"
  ],
  "temperature": 0.9,
  "topP": 1,
  "topK": 1
}

তালিকা মডেল

আপনি যদি models ডিরেক্টরি GET তবে এটি জেমিনি এবং পাম পরিবার উভয় মডেল সহ এপিআইয়ের মাধ্যমে উপলব্ধ সমস্ত মডেলগুলির তালিকা তৈরি করতে list পদ্ধতিটি ব্যবহার করে।

curl https://generativelanguage.googleapis.com/v1beta/models?key=$GOOGLE_API_KEY
{
  "models": [
    {
      "name": "models/chat-bison-001",
      "version": "001",
      "displayName": "Chat Bison",
      "description": "Chat-optimized generative language model.",
      "inputTokenLimit": 4096,
      "outputTokenLimit": 1024,
      "supportedGenerationMethods": [
        "generateMessage",
        "countMessageTokens"
      ],
      "temperature": 0.25,
      "topP": 0.95,
      "topK": 40
    },
    {
      "name": "models/text-bison-001",
      "version": "001",
      "displayName": "Text Bison",
      "description": "Model targeted for text generation.",
      "inputTokenLimit": 8196,
      "outputTokenLimit": 1024,
      "supportedGenerationMethods": [
        "generateText",
        "countTextTokens",
        "createTunedTextModel"
      ],
      "temperature": 0.7,
      "topP": 0.95,
      "topK": 40
    },
    {
      "name": "models/embedding-gecko-001",
      "version": "001",
      "displayName": "Embedding Gecko",
      "description": "Obtain a distributed representation of a text.",
      "inputTokenLimit": 1024,
      "outputTokenLimit": 1,
      "supportedGenerationMethods": [
        "embedText",
        "countTextTokens"
      ]
    },
    {
      "name": "models/embedding-gecko-002",
      "version": "002",
      "displayName": "Embedding Gecko 002",
      "description": "Obtain a distributed representation of a text.",
      "inputTokenLimit": 2048,
      "outputTokenLimit": 1,
      "supportedGenerationMethods": [
        "embedText",
        "countTextTokens"
      ]
    },
    {
      "name": "models/gemini-pro",
      "version": "001",
      "displayName": "Gemini Pro",
      "description": "The best model for scaling across a wide range of tasks",
      "inputTokenLimit": 30720,
      "outputTokenLimit": 2048,
      "supportedGenerationMethods": [
        "generateContent",
        "countTokens"
      ],
      "temperature": 0.9,
      "topP": 1,
      "topK": 1
    },
    {
      "name": "models/gemini-pro-vision",
      "version": "001",
      "displayName": "Gemini Pro Vision",
      "description": "The best image understanding model to handle a broad range of applications",
      "inputTokenLimit": 12288,
      "outputTokenLimit": 4096,
      "supportedGenerationMethods": [
        "generateContent",
        "countTokens"
      ],
      "temperature": 0.4,
      "topP": 1,
      "topK": 32
    },
    {
      "name": "models/gemini-ultra",
      "version": "001",
      "displayName": "Gemini Ultra",
      "description": "The most capable model for highly complex tasks",
      "inputTokenLimit": 30720,
      "outputTokenLimit": 2048,
      "supportedGenerationMethods": [
        "generateContent",
        "countTokens"
      ],
      "temperature": 0.9,
      "topP": 1,
      "topK": 32
    },
    {
      "name": "models/embedding-001",
      "version": "001",
      "displayName": "Embedding 001",
      "description": "Obtain a distributed representation of a text.",
      "inputTokenLimit": 2048,
      "outputTokenLimit": 1,
      "supportedGenerationMethods": [
        "embedContent",
        "countTextTokens"
      ]
    },
    {
      "name": "models/aqa",
      "version": "001",
      "displayName": "Model that performs Attributed Question Answering.",
      "description": "Model trained to return answers to questions that are grounded in provided sources, along with estimating answerable probability.",
      "inputTokenLimit": 7168,
      "outputTokenLimit": 1024,
      "supportedGenerationMethods": [
        "generateAnswer"
      ],
      "temperature": 0.2,
      "topP": 1,
      "topK": 40
    }
  ]
}