Vertex AI in Firebase SDK-এর GA সংস্করণ থেকে Firebase AI লজিক SDKগুলিতে স্থানান্তর করুন


Firebase AI Logic এবং এর ক্লায়েন্ট SDK-গুলো পূর্বে " Vertex AI in Firebase " নামে পরিচিত ছিল। আমাদের সম্প্রসারিত পরিষেবা এবং বৈশিষ্ট্যগুলোকে আরও ভালোভাবে তুলে ধরার জন্য (উদাহরণস্বরূপ, আমরা এখন Gemini Developer API সমর্থন করি!), আমরা আমাদের পরিষেবাগুলোর নাম পরিবর্তন করে Firebase AI Logic নামে নতুন করে প্যাকেজ করেছি

আপনার মোবাইল বা ওয়েব অ্যাপ থেকে সরাসরি এবং নিরাপদে গুগলের জেনারেটিভ এআই মডেলগুলো অ্যাক্সেস করার জন্য, আপনি এখন একটি ' জেমিনি এপিআই ' প্রোভাইডার বেছে নিতে পারেন — হয় বহু পুরোনো ভার্টেক্স এআই জেমিনি এপিআই অথবা নতুন জেমিনি ডেভেলপার এপিআই । এর মানে হলো, এখন আপনার কাছে জেমিনি ডেভেলপার এপিআই ব্যবহার করার সুযোগ রয়েছে, যা যুক্তিসঙ্গত রেট লিমিট এবং কোটা সহ একটি বিনামূল্যের স্তর প্রদান করে।

Overview of steps to migrate to the Firebase AI Logic SDKs

  • Step 1 : Choose the best " Gemini API " provider for your app and use cases.

  • Step 2 : Set up your Firebase project so that you can use the Gemini Developer API .
    Only applicable if you're swapping to use the Gemini Developer API instead of the Vertex AI Gemini API .

  • Step 3 : Update the library used in your app.

  • Step 4 : Update the initialization in your app.

  • Step 5 : Update your code depending on the features that you use.

ধাপ ১ : আপনার অ্যাপের জন্য সেরা 'জেমিনি এপিআই' প্রদানকারী বেছে নিন।

With this migration, you have a choice in " Gemini API " provider:

  • পুরানো " Vertex AI in Firebase " SDK-গুলো শুধুমাত্র Vertex AI Gemini API ব্যবহার করতে পারত।

  • নতুন Firebase AI Logic SDK-গুলো আপনাকে আপনার মোবাইল বা ওয়েব অ্যাপ থেকে সরাসরি কোন " Gemini API " প্রোভাইডারকে কল করতে চান তা বেছে নেওয়ার সুযোগ দেয় – হয় Gemini Developer API অথবা Vertex AI Gemini API

দুটি জেমিনি এপিআই প্রোভাইডার ব্যবহারের মধ্যেকার পার্থক্যগুলো পর্যালোচনা করুন, বিশেষ করে সমর্থিত ফিচার, মূল্য এবং রেট লিমিটের দিক থেকে। উদাহরণস্বরূপ, জেমিনি ডেভেলপার এপিআই Cloud Storage ইউআরএল ব্যবহার করে ফাইল সরবরাহ করা সমর্থন করে না, কিন্তু আপনি যদি এর বিনামূল্যের স্তর এবং যুক্তিসঙ্গত কোটার সুবিধা নিতে চান, তবে এটি একটি ভালো বিকল্প হতে পারে।

Step 2 : Set up your Firebase project so that you can use the Gemini Developer API

এই ধাপটি শুধুমাত্র তখনই প্রয়োজন হবে যদি আপনি Firebase AI Logic ক্লায়েন্ট SDK-গুলোর সাথে Gemini Developer API ব্যবহার শুরু করতে চান। তবে, আপনি যদি Vertex AI Gemini API-ই ব্যবহার করতে চান, তাহলে পরবর্তী ধাপে চলে যান।

মনে রাখবেন যে, আপনার প্রোজেক্টে একই সময়ে উভয় 'Gemini API' প্রোভাইডার সক্রিয় রাখলে কোনো সমস্যা নেই।

  1. In the Firebase console, go to AI Services > AI Logic .

  2. Go to the Settings tab, and select Gemini Developer API .

  3. Enable the Gemini Developer API .

    The console will make sure the required APIs are enabled and generate a Gemini API key in your Firebase project.
    Do not add this Gemini API key into your app's codebase. Learn more.

  4. Continue in this migration guide to update the library and initialization in your app.

Step 3 : Update the library used in your app

Update your app's codebase to use the Firebase AI Logic library.

সুইফট

  1. Xcode-এ, আপনার অ্যাপ প্রজেক্টটি খোলা রেখে, নিম্নলিখিত বিকল্পগুলির মধ্যে যেকোনো একটি ব্যবহার করে আপনার Firebase প্যাকেজটি v11.13.0 বা তার পরবর্তী সংস্করণে আপডেট করুন:

    • Option 1 : Update all packages: Navigate to File > Packages > Update to Latest Package Versions .

    • বিকল্প ২ : পৃথকভাবে ফায়ারবেস আপডেট করুন: 'প্যাকেজ ডিপেন্ডেন্সি' নামক বিভাগে ফায়ারবেস প্যাকেজটিতে যান। ফায়ারবেস প্যাকেজটির উপর রাইট-ক্লিক করুন এবং তারপর 'আপডেট প্যাকেজ' নির্বাচন করুন।

  2. Make sure that the Firebase package now shows v11.13.0 or later. If it doesn't, verify that your specified Package Requirements allow updating to v11.13.0 or later.

  3. Select your app's target in the Project Editor, and then navigate to the Frameworks, Libraries, and Embedded Content section.

  4. Add the new library: Select the + button, and then add FirebaseAI from the Firebase package.

  5. After you've finished migrating your app (see the remaining sections in this guide), make sure to remove the old library:
    Select FirebaseVertexAI , and then press the button.

Kotlin

  1. আপনার মডিউল (অ্যাপ-লেভেল) গ্রেডল ফাইলে (সাধারণত <project>/<app-module>/build.gradle.kts অথবা <project>/<app-module>/build.gradle ), পুরোনো ডিপেন্ডেন্সিগুলো (প্রযোজ্য ক্ষেত্রে) নিম্নলিখিতগুলো দিয়ে প্রতিস্থাপন করুন।

    Note that it might be easier to migrate your app's codebase (see the remaining sections in this guide) before deleting the old dependency.

    // BEFORE
    dependencies {
      implementation(platform("com.google.firebase:firebase-bom:33.x.y"))
      implementation("com.google.firebase:firebase-vertexai")
      // OR if not using the BoM
      implementation("com.google.firebase:firebase-vertexai:16.x.y")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.15.0"))
    
      // Add the dependency for the Firebase AI Logic library
      // When using the BoM, you don't specify versions in Firebase library dependencies
      implementation("com.google.firebase:firebase-ai")
    }
  2. Sync your Android project with Gradle files.

Note that if you choose to not use the Firebase Android BoM , then just add the dependency for the firebase-ai library and accept the latest version that's suggested by Android Studio.

Java

  1. আপনার মডিউল (অ্যাপ-লেভেল) গ্রেডল ফাইলে (সাধারণত <project>/<app-module>/build.gradle.kts অথবা <project>/<app-module>/build.gradle ), পুরোনো ডিপেন্ডেন্সিগুলো (প্রযোজ্য ক্ষেত্রে) নিম্নলিখিতগুলো দিয়ে প্রতিস্থাপন করুন।

    Note that it might be easier to migrate your app's codebase (see the remaining sections in this guide) before deleting the old dependency.

    // BEFORE
    dependencies {
      implementation(platform("com.google.firebase:firebase-bom:33.x.y"))
      implementation("com.google.firebase:firebase-vertexai")
      // OR if not using the BoM
      implementation("com.google.firebase:firebase-vertexai:16.x.y")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.15.0"))
    
      // Add the dependency for the Firebase AI Logic library
      // When using the BoM, you don't specify versions in Firebase library dependencies
      implementation("com.google.firebase:firebase-ai")
    }
  2. Sync your Android project with Gradle files.

মনে রাখবেন, যদি আপনি Firebase Android BoM ব্যবহার না করার সিদ্ধান্ত নেন, তাহলে শুধু firebase-ai লাইব্রেরির ডিপেন্ডেন্সিটি যোগ করুন এবং Android Studio দ্বারা প্রস্তাবিত সর্বশেষ সংস্করণটি গ্রহণ করুন।

Web

  1. Get the latest version of the Firebase JS SDK for Web using npm:

    npm i firebase@latest

    অথবা

    yarn add firebase@latest
  2. আপনি যেখানেই লাইব্রেরিটি ইম্পোর্ট করেছেন, সেখানে firebase/ai ব্যবহার করার জন্য আপনার ইম্পোর্ট স্টেটমেন্টগুলো আপডেট করুন।

    Note that it might be easier to migrate your app's codebase (see the remaining sections in this guide) before deleting the old imports.

    // BEFORE
    import { initializeApp } from "firebase/app";
    import { getVertexAI, getGenerativeModel } from "firebase/vertexai";
    
    
    // AFTER
    import { initializeApp } from "firebase/app";
    import { getAI, getGenerativeModel } from "firebase/ai";

Dart

  1. আপনার ফ্লাটার প্রজেক্ট ডিরেক্টরি থেকে নিম্নলিখিত কমান্ডটি চালিয়ে আপনার pubspec.yaml ফাইলে firebase_ai প্যাকেজটি ব্যবহার করার জন্য ফাইলটি আপডেট করুন:

    flutter pub add firebase_ai
  2. Rebuild your Flutter project:

    flutter run
  3. আপনার অ্যাপ মাইগ্রেট করা শেষ হলে (এই গাইডের বাকি অংশগুলো দেখুন), পুরোনো প্যাকেজটি ডিলিট করে দিতে ভুলবেন না:

    flutter pub remove firebase_vertexai

ঐক্য

" ফায়ারবেসে ভার্টেক্স এআই " থেকে ইউনিটির জন্য সমর্থন পাওয়া যাচ্ছিল না।

ইউনিটির জন্য ফায়ারবেস এআই লজিক এসডিকে (Firebase AI Logic SDK for Unity) দিয়ে কীভাবে কাজ শুরু করবেন তা জেনে নিন।

Step 4 : Update the initialization in your app

এই পৃষ্ঠায় প্রদানকারী-নির্দিষ্ট বিষয়বস্তু এবং কোড দেখতে আপনার জেমিনি এপিআই প্রদানকারীর উপর ক্লিক করুন।

আপনার নির্বাচিত এপিআই প্রোভাইডারের জন্য সার্ভিসটি ইনিশিয়ালাইজ করার পদ্ধতি আপডেট করুন এবং একটি GenerativeModel ইনস্ট্যান্স তৈরি করুন।

সুইফট


import FirebaseAILogic

// Initialize the Vertex AI Gemini API backend service.
// Specify `global` as the location to access the model.
let ai = FirebaseAI.firebaseAI(backend: .vertexAI(location: "global"))

// Create a `GenerativeModel` instance with a model that supports your use case
let model = ai.generativeModel(modelName: "gemini-3.5-flash")

Kotlin


// Initialize the Vertex AI Gemini API backend service.
// Specify `global` as the location to access the model.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.vertexAI(location = "global"))
                        .generativeModel("gemini-3.5-flash")

Java


// Initialize the Vertex AI Gemini API backend service.
// Specify `global` as the location to access the model.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.vertexAI("global"))
        .generativeModel("gemini-3.5-flash");

// Use the GenerativeModelFutures Java compatibility layer which offers
// support for ListenableFuture and Publisher APIs
GenerativeModelFutures model = GenerativeModelFutures.from(ai);

Web


import { initializeApp } from "firebase/app";
import { getAI, getGenerativeModel, VertexAIBackend } from "firebase/ai";

// TODO(developer) Replace the following with your app's Firebase configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
  // ...
};

// Initialize FirebaseApp
const firebaseApp = initializeApp(firebaseConfig);

// Initialize the Vertex AI Gemini API backend service.
// Specify `global` as the location to access the model.
const ai = getAI(firebaseApp, { backend: new VertexAIBackend('global') });

// Create a `GenerativeModel` instance with a model that supports your use case
const model = getGenerativeModel(ai, { model: "gemini-3.5-flash" });

Dart


import 'package:firebase_ai/firebase_ai.dart';
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';

// Initialize FirebaseApp
await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

// Initialize the Vertex AI Gemini API backend service.
// Specify `global` as the location to access the model.
// Create a `GenerativeModel` instance with a model that supports your use case.
final model =
      FirebaseAI.vertexAI(location: 'global').generativeModel(model: 'gemini-3.5-flash');

ঐক্য

" ফায়ারবেসে ভার্টেক্স এআই " থেকে ইউনিটির জন্য সমর্থন পাওয়া যাচ্ছিল না।

ইউনিটির জন্য ফায়ারবেস এআই লজিক এসডিকে (Firebase AI Logic SDK for Unity) দিয়ে কীভাবে কাজ শুরু করবেন তা জেনে নিন।

মনে রাখবেন যে , আপনি কোন সক্ষমতা ব্যবহার করছেন তার উপর নির্ভর করে, আপনাকে সবসময় একটি GenerativeModel ইনস্ট্যান্স তৈরি করতে নাও হতে পারেGemini Live API ব্যবহার করে ইনপুট এবং আউটপুট স্ট্রিম করতে , একটি LiveModel ইনস্ট্যান্স তৈরি করুন।

ধাপ ৫ : আপনার ব্যবহৃত ফিচারগুলোর ওপর নির্ভর করে কোড আপডেট করুন।

এই ধাপে আপনার ব্যবহৃত ফিচারগুলোর ওপর নির্ভর করে প্রয়োজনীয় পরিবর্তনগুলো বর্ণনা করা হয়েছে।

  • আপনি যদি Cloud Storage ইউআরএল ব্যবহার করে থাকেন এবং এই মাইগ্রেশনে জেমিনি ডেভেলপার এপিআই ব্যবহার শুরু করে থাকেন, তাহলে ফাইলগুলিকে ইনলাইন ডেটা হিসেবে অন্তর্ভুক্ত করার জন্য আপনাকে আপনার মাল্টিমোডাল রিকোয়েস্টগুলি আপডেট করতে হবে (অথবা ভিডিওর জন্য ইউটিউব ইউআরএল ব্যবহার করতে হবে)।

  • Firebase AI Logic SDK ব্যবহারের জন্য আপনার কোডে কোনো পরিবর্তন আনার প্রয়োজন হতে পারে কিনা, তা জানতে নিচের তালিকাগুলো পর্যালোচনা করুন।

সুইফট

No additional changes.

Kotlin

  • Live API

    • ResponseModality enum ক্লাসের জন্য UNSPECIFIED ভ্যালুটি সরিয়ে ফেলা হয়েছে। এর পরিবর্তে null ব্যবহার করুন।

Java

  • Live API

    • ResponseModality enum ক্লাসের জন্য UNSPECIFIED ভ্যালুটি সরিয়ে ফেলা হয়েছে। এর পরিবর্তে null ব্যবহার করুন।
  • বিভিন্ন জাভা বিল্ডার মেথড পরিবর্তন করা হয়েছে, যাতে এখন থেকে এগুলো void-এর পরিবর্তে সঠিকভাবে তাদের ক্লাসের ইনস্ট্যান্স রিটার্ন করে।

Web

শুধুমাত্র তখনই পরিবর্তন প্রয়োজন হবে, যদি আপনি Vertex AI Gemini API- এর পরিবর্তে Gemini Developer API ব্যবহার শুরু করেন :

  • Safety settings

    • অসমর্থিত SafetySetting.method এর ব্যবহারগুলো সরিয়ে ফেলা হয়েছে।
  • Inline data

    • অসমর্থিত InlineDataPart.videoMetadata এর ব্যবহারগুলো সরিয়ে ফেলা হয়েছে।

Dart

No additional changes.

ঐক্য

" ফায়ারবেসে ভার্টেক্স এআই " থেকে ইউনিটির জন্য সমর্থন পাওয়া যাচ্ছিল না।

ইউনিটির জন্য ফায়ারবেস এআই লজিক এসডিকে (Firebase AI Logic SDK for Unity) দিয়ে কীভাবে কাজ শুরু করবেন তা জেনে নিন।


Firebase AI Logic ব্যবহারের অভিজ্ঞতা সম্পর্কে মতামত দিন।