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


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

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

Firebase AI Logic SDK-গুলিতে স্থানান্তরের ধাপগুলির সংক্ষিপ্ত বিবরণ

  • ধাপ ১ : আপনার অ্যাপ এবং ব্যবহারের ক্ষেত্র অনুযায়ী সেরা 'জেমিনি এপিআই' প্রদানকারী বেছে নিন।

  • ধাপ ২ : প্রয়োজনীয় API-গুলো সক্রিয় করুন।

  • ধাপ ৩ : আপনার অ্যাপে ব্যবহৃত লাইব্রেরিটি আপডেট করুন।

  • ধাপ ৪ : আপনার অ্যাপে প্রারম্ভিককরণ আপডেট করুন।

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

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

এই মাইগ্রেশনের মাধ্যমে, আপনার কাছে ' জেমিনি এপিআই ' প্রদানকারী বেছে নেওয়ার সুযোগ রয়েছে:

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

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

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

ধাপ ২ : প্রয়োজনীয় API গুলো সক্রিয় করুন

আপনার নির্বাচিত ' Gemini API ' প্রোভাইডার ব্যবহার করার জন্য আপনার Firebase প্রোজেক্টে সমস্ত প্রয়োজনীয় API সক্রিয় করা আছে কিনা তা নিশ্চিত করুন।

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

  1. Firebase কনসোলে সাইন ইন করুন এবং তারপরে আপনার ফায়ারবেস প্রজেক্টটি নির্বাচন করুন।

  2. Firebase কনসোলে, AI Services > AI Logic- এ যান।

  3. আপনার প্রোজেক্টের জন্য প্রয়োজনীয় এপিআই ও রিসোর্স সেট আপ করতে সাহায্যকারী একটি নির্দেশিত ওয়ার্কফ্লো চালু করতে 'Get started'- এ ক্লিক করুন।

  4. আপনি Firebase AI Logic SDK-গুলোর সাথে যে 'Gemini API' প্রোভাইডারটি ব্যবহার করতে চান, সেটি নির্বাচন করুন। আপনি চাইলে পরবর্তীতে যেকোনো সময় অন্য API প্রোভাইডারটি সেট আপ করে ব্যবহার করতে পারেন।

    • জেমিনি ডেভেলপার এপিআইবিলিং ঐচ্ছিক (বিনামূল্যের স্পার্ক প্রাইসিং প্ল্যানে উপলব্ধ)
      কনসোলের ওয়ার্কফ্লো আপনার প্রোজেক্টে প্রয়োজনীয় API-গুলো সক্রিয় করবে এবং একটি Gemini API কী তৈরি করবে।
      এই জেমিনি এপিআই কী-টি আপনার অ্যাপের কোডবেসে যোগ করবেন না আরও জানুন।

    • এজেন্ট প্ল্যাটফর্ম জেমিনি এপিআই (পূর্বে ভার্টেক্স এআই)বিলিং আবশ্যক (এর জন্য পে-অ্যাজ-ইউ-গো ব্লেজ প্রাইসিং প্ল্যান প্রয়োজন)
      কনসোলের ওয়ার্কফ্লো আপনার প্রোজেক্টে প্রয়োজনীয় এপিআইগুলো সক্রিয় করবে।

  5. আপনার অ্যাপে লাইব্রেরি ও ইনিশিয়ালাইজেশন আপডেট করতে এই মাইগ্রেশন গাইডটি অনুসরণ করুন।

ধাপ ৩ : আপনার অ্যাপে ব্যবহৃত লাইব্রেরিটি আপডেট করুন।

Firebase AI Logic লাইব্রেরি ব্যবহার করার জন্য আপনার অ্যাপের কোডবেস আপডেট করুন।

সুইফট

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

    • বিকল্প ১ : সমস্ত প্যাকেজ আপডেট করুন: ফাইল > প্যাকেজ > সর্বশেষ প্যাকেজ সংস্করণে আপডেট করুন-এ যান।

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

  2. নিশ্চিত করুন যে Firebase প্যাকেজটিতে এখন v11.13.0 বা তার পরবর্তী সংস্করণ দেখাচ্ছে। যদি তা না দেখায়, তবে যাচাই করুন যে আপনার নির্দিষ্ট করা প্যাকেজ রিকোয়ারমেন্টস (Package Requirements) অনুযায়ী v11.13.0 বা তার পরবর্তী সংস্করণে আপডেট করা যাবে কিনা।

  3. প্রজেক্ট এডিটর-এ আপনার অ্যাপের লক্ষ্য নির্বাচন করুন, এবং তারপর ফ্রেমওয়ার্কস, লাইব্রেরিস, এবং এমবেডেড কন্টেন্ট সেকশনে যান।

  4. নতুন লাইব্রেরিটি যোগ করুন: + বোতামটি নির্বাচন করুন, এবং তারপরে Firebase প্যাকেজ থেকে FirebaseAI যোগ করুন।

  5. আপনার অ্যাপ মাইগ্রেট করা শেষ হলে (এই গাইডের বাকি অংশগুলো দেখুন), পুরোনো লাইব্রেরিটি অবশ্যই মুছে ফেলবেন:
    FirebaseVertexAI-Preview নির্বাচন করুন, এবং তারপর বোতামটি চাপুন।

Kotlin

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

    মনে রাখবেন যে, পুরোনো ডিপেন্ডেন্সিটি ডিলিট করার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

    // BEFORE
    dependencies {
      implementation("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. আপনার অ্যান্ড্রয়েড প্রজেক্টকে গ্রেডল ফাইলের সাথে সিঙ্ক করুন।

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

Java

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

    মনে রাখবেন যে, পুরোনো ডিপেন্ডেন্সিটি ডিলিট করার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

    // BEFORE
    dependencies {
      implementation("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. আপনার অ্যান্ড্রয়েড প্রজেক্টকে গ্রেডল ফাইলের সাথে সিঙ্ক করুন।

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

Web

  1. npm ব্যবহার করে ওয়েবের জন্য Firebase JS SDK-এর সর্বশেষ সংস্করণটি ডাউনলোড করুন:

    npm i firebase@latest

    অথবা

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

    মনে রাখবেন যে, পুরোনো ইম্পোর্টগুলো মুছে ফেলার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

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

Dart

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

    flutter pub add firebase_ai
  2. আপনার ফ্লাটার প্রজেক্টটি পুনর্গঠন করুন:

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

    flutter pub remove firebase_vertexai

ঐক্য

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

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

ধাপ ৪ : আপনার অ্যাপে প্রারম্ভিককরণ আপডেট করুন।

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

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

সুইফট


import FirebaseAILogic

// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

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

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
                        .generativeModel("gemini-3.7-flash")

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
        .generativeModel("gemini-3.7-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, GoogleAIBackend } 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 Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(ai, { model: "gemini-3.7-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 Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
      FirebaseAI.googleAI().generativeModel(model: 'gemini-3.7-flash');

ঐক্য

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

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

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

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

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

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

  • " Vertex AI in Firebase " SDK-এর GA সংস্করণগুলিতে বেশ কিছু পরিবর্তন আনা হয়েছে। Firebase AI Logic SDK ব্যবহার করার জন্যও এই একই পরিবর্তনগুলি আবশ্যক। Firebase AI Logic SDK ব্যবহারের জন্য আপনার কোডে কী কী পরিবর্তন করতে হতে পারে, তা জানতে নিচের তালিকাগুলি পর্যালোচনা করুন।

সকল ভাষা এবং প্ল্যাটফর্মের জন্য আবশ্যক

  • ফাংশন কলিং
    আপনি যদি GA-এর আগে এই ফিচারটি প্রয়োগ করে থাকেন, তাহলে আপনার স্কিমা সংজ্ঞায়িত করার পদ্ধতিতে আপডেট আনতে হবে। আপনার ফাংশন ডিক্লারেশনগুলো কীভাবে লিখতে হয় তা জানতে আমরা আপডেট করা ফাংশন কলিং গাইডটি পর্যালোচনা করার পরামর্শ দিচ্ছি।

  • responseSchema ব্যবহার করে কাঠামোগত আউটপুট (যেমন JSON) তৈরি করা
    আপনি যদি GA-এর আগে এই ফিচারটি প্রয়োগ করে থাকেন, তাহলে আপনার স্কিমা সংজ্ঞায়িত করার পদ্ধতিতে আপডেট আনতে হবে। JSON স্কিমা কীভাবে লিখতে হয় তা জানতে আমরা নতুন স্ট্রাকচার্ড আউটপুট গাইডটি পর্যালোচনা করার পরামর্শ দিচ্ছি।

  • টাইমআউট

    • অনুরোধের জন্য ডিফল্ট টাইমআউট পরিবর্তন করে ১৮০ সেকেন্ড করা হয়েছে।

প্ল্যাটফর্ম বা ভাষার উপর ভিত্তি করে প্রয়োজন

সুইফট

  • গণনা

    • বেশিরভাগ enum টাইপকে স্ট্যাটিক ভেরিয়েবল সহ struct দিয়ে প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি API-কে ব্যাকওয়ার্ড-কম্প্যাটিবল উপায়ে উন্নত করার জন্য আরও বেশি নমনীয়তা প্রদান করে। switch স্টেটমেন্ট ব্যবহার করার সময়, অজানা বা আনহ্যান্ডেলড ভ্যালুগুলো কভার করার জন্য আপনাকে এখন অবশ্যই একটি default: case অন্তর্ভুক্ত করতে হবে, যার মধ্যে ভবিষ্যতে SDK-তে যুক্ত হওয়া নতুন ভ্যালুগুলোও অন্তর্ভুক্ত থাকবে।

    • BlockThreshold এনুমারেশনটির নাম পরিবর্তন করে HarmBlockThreshold রাখা হয়েছে; এই টাইপটি এখন একটি struct

    • নিম্নলিখিত এনুমারেশনগুলি (এখন struct s) থেকে unknown এবং unspecified কেসগুলি সরানো হয়েছে: HarmCategory , HarmBlockThreshold , HarmProbability , BlockReason , এবং FinishReason

    • পূর্ববর্তী সংস্করণের সাথে সামঞ্জস্যপূর্ণভাবে নতুন টাইপ যুক্ত করার সুযোগ দিতে, ModelContent.Part এনুমারেশনটিকে Part নামক একটি প্রোটোকল দ্বারা প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি Content parts বিভাগে আরও বিস্তারিতভাবে বর্ণনা করা হয়েছে।

  • বিষয়বস্তুর অংশ

    • মাঝেমধ্যে ঘটা কম্পাইলার ত্রুটি এড়ানোর জন্য ThrowingPartsRepresentable প্রোটোকলটি সরিয়ে দেওয়া হয়েছে এবং ModelContent এর ইনিশিয়ালাইজারগুলোকে সরল করা হয়েছে। যেসব ইমেজ সঠিকভাবে এনকোড হয় না, সেগুলো generateContent এ ব্যবহার করার সময় এখনও ত্রুটি দেখাবে।

    • Part প্রোটোকল মেনে ModelContent.Part কেসগুলোকে নিম্নলিখিত struct টাইপগুলো দ্বারা প্রতিস্থাপন করা হয়েছে:

      • .text to TextPart
      • .data to InlineDataPart
      • .fileData থেকে FileDataPart
      • .functionCall থেকে FunctionCallPart
      • .functionResponse to FunctionResponsePart
  • ক্ষতির বিভাগ

    • HarmCategory এখন আর SafetySetting টাইপের মধ্যে নেস্টেড রাখা হবে না। আপনি যদি এটিকে SafetySetting.HarmCategory হিসেবে উল্লেখ করে থাকেন, তবে সেটিকে HarmCategory দিয়ে প্রতিস্থাপন করা যাবে।
  • নিরাপত্তা প্রতিক্রিয়া

    • SafetyFeedback টাইপটি সরিয়ে দেওয়া হয়েছে, কারণ এটি কোনো প্রতিক্রিয়ায় ব্যবহৃত হয়নি।
  • উদ্ধৃতি মেটাডেটা

    • CitationMetadata তে citationSources প্রপার্টির নাম পরিবর্তন করে citations রাখা হয়েছে।
  • মোট বিলযোগ্য অক্ষর

    • CountTokensResponse এর totalBillableCharacters প্রপার্টিটিকে ঐচ্ছিক করা হয়েছে, যাতে কোনো ক্যারেক্টার পাঠানো না হলে সেই পরিস্থিতিও প্রতিফলিত হয়।
  • প্রার্থীর প্রতিক্রিয়া

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে CandidateResponse নাম পরিবর্তন করে Candidate রাখা হয়েছে।
  • প্রজন্মের কনফিগারেশন

    • GenerationConfig এর পাবলিক প্রপার্টিগুলোকে internal এ পরিবর্তন করা হয়েছে। ইনিশিয়ালাইজারে এগুলো সবই কনফিগারযোগ্য থাকবে।

Kotlin

  • গণনা

    • enum ক্লাস এবং sealed ক্লাসগুলোকে সাধারণ ক্লাস দিয়ে প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি API-কে পশ্চাৎ সামঞ্জস্যপূর্ণ (backward compatible) উপায়ে বিকশিত করার জন্য আরও বেশি নমনীয়তা প্রদান করে।

    • BlockThreshold এনুমারেশনটির নাম পরিবর্তন করে HarmBlockThreshold রাখা হয়েছে।

    • নিম্নলিখিত এনুমারেশনগুলো থেকে মানগুলো মুছে ফেলা হয়েছে: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , এবং FinishReason

  • ব্লব পদ্ধতি

    • যেসব মেথডের নামের অংশ হিসেবে Blob অন্তর্ভুক্ত ছিল, সেগুলোর নাম পরিবর্তন করে InlineData ব্যবহার করা হয়েছে।
  • নিরাপত্তা সেটিংস

    • ফিল্ড method নালযোগ্য করা হয়েছে।
  • সময়কাল শ্রেণী

    • কোটলিনের Duration ক্লাসের সমস্ত ব্যবহার সরিয়ে দিয়ে এর পরিবর্তে long ব্যবহার করা হয়েছে। এই পরিবর্তনটি জাভার সাথে উন্নততর আন্তঃকার্যক্ষমতা প্রদান করে।
  • উদ্ধৃতি মেটাডেটা

    • পূর্বে CitationMetadata তে ঘোষিত সমস্ত ফিল্ডকে Citation নামক একটি নতুন ক্লাসের অধীনে আনা হয়েছে। CitationMetadata এর citations নামক তালিকায় সাইটেশনগুলো পাওয়া যাবে। এই পরিবর্তনটি বিভিন্ন প্ল্যাটফর্মে টাইপগুলোর আরও ভালো সামঞ্জস্য বিধান করে।
  • টোকেন গণনা করুন

    • totalBillableCharacters ফিল্ডটিকে নাল (null) করা হয়েছে।
  • মোট বিলযোগ্য অক্ষর

    • CountTokensResponse এর totalBillableCharacters প্রপার্টিটিকে ঐচ্ছিক করা হয়েছে, যাতে কোনো ক্যারেক্টার পাঠানো না হলে সেই পরিস্থিতিও প্রতিফলিত হয়।
  • একটি মডেল ইনস্ট্যানশিয়েট করা

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে requestOptions প্যারামিটারটিকে প্যারামিটার তালিকার শেষে সরানো হয়েছে।
  • Live API

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

    • LiveGenerationConfig.setResponseModalities নাম পরিবর্তন করে LiveGenerationConfig.setResponseModality রাখা হয়েছে।

    • LiveContentResponse.Status ক্লাসটি সরিয়ে দেওয়া হয়েছে এবং এর পরিবর্তে স্ট্যাটাস ফিল্ডগুলোকে LiveContentResponse এর প্রপার্টি হিসেবে নেস্ট করা হয়েছে।

    • LiveContentResponse ক্লাসটি সরিয়ে দেওয়া হয়েছে এবং এর পরিবর্তে LiveServerMessage এর সাবক্লাস দেওয়া হয়েছে যা মডেলের রেসপন্সগুলোর সাথে মেলে।

    • LiveModelFutures.connect কে ListenableFuture<LiveSessionFutures> ListenableFuture<LiveSession> এর পরিবর্তে ListenableFuture<LiveSessionFutures> রিটার্ন করার জন্য পরিবর্তন করা হয়েছে।

Java

  • গণনা

    • enum ক্লাস এবং sealed ক্লাসগুলোকে সাধারণ ক্লাস দিয়ে প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি API-কে পশ্চাৎ সামঞ্জস্যপূর্ণ (backward compatible) উপায়ে বিকশিত করার জন্য আরও বেশি নমনীয়তা প্রদান করে।

    • BlockThreshold এনুমারেশনটির নাম পরিবর্তন করে HarmBlockThreshold রাখা হয়েছে।

    • নিম্নলিখিত এনুমারেশনগুলো থেকে মানগুলো মুছে ফেলা হয়েছে: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , এবং FinishReason

  • ব্লব পদ্ধতি

    • যেসব মেথডের নামের অংশ হিসেবে Blob অন্তর্ভুক্ত ছিল, সেগুলোর নাম পরিবর্তন করে InlineData ব্যবহার করা হয়েছে।
  • নিরাপত্তা সেটিংস

    • ফিল্ড method নালযোগ্য করা হয়েছে।
  • সময়কাল শ্রেণী

    • কোটলিনের Duration ক্লাসের সমস্ত ব্যবহার সরিয়ে দিয়ে এর পরিবর্তে long ব্যবহার করা হয়েছে। এই পরিবর্তনটি জাভার সাথে উন্নততর আন্তঃকার্যক্ষমতা প্রদান করে।
  • উদ্ধৃতি মেটাডেটা

    • পূর্বে CitationMetadata তে ঘোষিত সমস্ত ফিল্ডকে Citation নামক একটি নতুন ক্লাসের অধীনে আনা হয়েছে। CitationMetadata এর citations নামক তালিকায় সাইটেশনগুলো পাওয়া যাবে। এই পরিবর্তনটি বিভিন্ন প্ল্যাটফর্মে টাইপগুলোর আরও ভালো সামঞ্জস্য বিধান করে।
  • টোকেন গণনা করুন

    • totalBillableCharacters ফিল্ডটিকে নাল (null) করা হয়েছে।
  • মোট বিলযোগ্য অক্ষর

    • CountTokensResponse এর totalBillableCharacters প্রপার্টিটিকে ঐচ্ছিক করা হয়েছে, যাতে কোনো ক্যারেক্টার পাঠানো না হলে সেই পরিস্থিতিও প্রতিফলিত হয়।
  • একটি মডেল ইনস্ট্যানশিয়েট করা

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে requestOptions প্যারামিটারটিকে প্যারামিটার তালিকার শেষে সরানো হয়েছে।
  • Live API

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

    • LiveGenerationConfig.setResponseModalities নাম পরিবর্তন করে LiveGenerationConfig.setResponseModality রাখা হয়েছে।

    • LiveContentResponse.Status ক্লাসটি সরিয়ে দেওয়া হয়েছে এবং এর পরিবর্তে স্ট্যাটাস ফিল্ডগুলোকে LiveContentResponse এর প্রপার্টি হিসেবে নেস্ট করা হয়েছে।

    • LiveContentResponse ক্লাসটি সরিয়ে দেওয়া হয়েছে এবং এর পরিবর্তে LiveServerMessage এর সাবক্লাস দেওয়া হয়েছে যা মডেলের রেসপন্সগুলোর সাথে মেলে।

    • LiveModelFutures.connect কে ListenableFuture<LiveSessionFutures> ListenableFuture<LiveSession> এর পরিবর্তে ListenableFuture<LiveSessionFutures> রিটার্ন করার জন্য পরিবর্তন করা হয়েছে।

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

Web

  • গণনা

    • নিম্নলিখিত এনুমারেশনগুলো থেকে মানগুলো মুছে ফেলা হয়েছে: HarmCategory , BlockThreshold , HarmProbability , HarmSeverity , BlockReason , এবং FinishReason
  • ব্লক কারণ

    • PromptFeedback এর blockReason ঐচ্ছিক করা হয়েছে।

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

  • নিরাপত্তা সেটিংস

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

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

Dart

  • গণনা

    • নিম্নলিখিত এনুমারেশনগুলো থেকে মানগুলো মুছে ফেলা হয়েছে: HarmCategory , HarmProbability , BlockReason , এবং FinishReason
  • ডেটা অংশ

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে DataPart নাম পরিবর্তন করে InlineDataPart রাখা হয়েছে এবং static data ফাংশনের নাম পরিবর্তন করে inlineData রাখা হয়েছে।
  • অনুরোধের বিকল্পগুলি

    • timeout কার্যকর না থাকায় RequestOptions সরিয়ে ফেলা হয়েছে। এটি শীঘ্রই পুনরায় যোগ করা হবে এবং অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে এটিকে GenerativeModel টাইপে স্থানান্তর করা হবে।
  • স্টপ সিকোয়েন্স

    • GenerationConfig এর stopSequences প্যারামিটারটিকে ঐচ্ছিক করা হয়েছে এবং এর ডিফল্ট মান একটি খালি অ্যারের পরিবর্তে null রাখা হয়েছে।
  • উদ্ধৃতি

    • CitationMetadata তে citationSources প্রপার্টির নাম পরিবর্তন করে citations রাখা হয়েছে। অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে CitationSource টাইপের নাম পরিবর্তন করে Citation রাখা হয়েছে।
  • অপ্রয়োজনীয় পাবলিক টাইপ, মেথড এবং প্রোপার্টি

    • অনিচ্ছাকৃতভাবে উন্মুক্ত হয়ে যাওয়া নিম্নলিখিত টাইপ, মেথড এবং প্রোপার্টিগুলো সরিয়ে ফেলা হয়েছে: defaultTimeout , CountTokensResponseFields , parseCountTokensResponse , parseEmbedContentResponse , parseGenerateContentResponse , parseContent , BatchEmbedContentsResponse , ContentEmbedding , EmbedContentRequest , এবং EmbedContentResponse
  • টোকেন গণনা করুন

    • countTokens ফাংশন থেকে অপ্রয়োজনীয় অতিরিক্ত ফিল্ডগুলো সরিয়ে দেওয়া হয়েছে। এখন শুধু contents ই প্রয়োজন।
  • একটি মডেল ইনস্ট্যানশিয়েট করা

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে systemInstruction প্যারামিটারটিকে প্যারামিটার তালিকার শেষে সরানো হয়েছে।
  • এমবেডিং কার্যকারিতা

    • মডেল থেকে অসমর্থিত এমবেডিং কার্যকারিতা ( embedContent এবং batchEmbedContents ) সরিয়ে ফেলা হয়েছে।

ঐক্য

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

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

স্থানান্তর সম্পর্কিত সম্ভাব্য ত্রুটিসমূহ

আপনি যখন Firebase AI Logic- এর GA সংস্করণটি ব্যবহার করার জন্য মাইগ্রেট করছেন, তখন এই মাইগ্রেশন গাইডে বর্ণিত সমস্ত প্রয়োজনীয় পরিবর্তনগুলি সম্পন্ন না করে থাকলে আপনি ত্রুটির সম্মুখীন হতে পারেন।

৪০৩ ত্রুটি: Requests to this API firebasevertexai.googleapis.com ... are blocked.

যদি আপনি Requests to this API firebasevertexai.googleapis.com ... are blocked. লেখা একটি 403 এরর পান, তাহলে এর মানে সাধারণত এই যে, আপনার Firebase কনফিগারেশন ফাইল বা অবজেক্টে থাকা Firebase API কী-টির allowlist-এ আপনি যে প্রোডাক্টটি ব্যবহার করার চেষ্টা করছেন তার জন্য প্রয়োজনীয় API-টি নেই।

নিশ্চিত করুন যে আপনার অ্যাপে ব্যবহৃত Firebase API কী- এর "API restrictions" allowlist-এ সমস্ত প্রয়োজনীয় API অন্তর্ভুক্ত আছে। Firebase AI Logic-এর জন্য, আপনার Firebase API কী-এর allowlist-এ ন্যূনতম Firebase AI Logic API-টি থাকা প্রয়োজন। আপনি যখন Firebase কনসোলে প্রয়োজনীয় API-গুলো সক্রিয় করেছিলেন , তখন এই API-টি স্বয়ংক্রিয়ভাবে আপনার API কী-এর allowlist-এ যুক্ত হয়ে যাওয়ার কথা।

আপনি Google Cloud কনসোলের APIs & Services > Credentials প্যানেলে আপনার সমস্ত API কী দেখতে পারেন।


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


,


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

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

Firebase AI Logic SDK-গুলিতে স্থানান্তরের ধাপগুলির সংক্ষিপ্ত বিবরণ

  • ধাপ ১ : আপনার অ্যাপ এবং ব্যবহারের ক্ষেত্র অনুযায়ী সেরা 'জেমিনি এপিআই' প্রদানকারী বেছে নিন।

  • ধাপ ২ : প্রয়োজনীয় API-গুলো সক্রিয় করুন।

  • ধাপ ৩ : আপনার অ্যাপে ব্যবহৃত লাইব্রেরিটি আপডেট করুন।

  • ধাপ ৪ : আপনার অ্যাপে প্রারম্ভিককরণ আপডেট করুন।

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

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

এই মাইগ্রেশনের মাধ্যমে, আপনার কাছে ' জেমিনি এপিআই ' প্রদানকারী বেছে নেওয়ার সুযোগ রয়েছে:

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

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

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

ধাপ ২ : প্রয়োজনীয় API গুলো সক্রিয় করুন

আপনার নির্বাচিত ' Gemini API ' প্রোভাইডার ব্যবহার করার জন্য আপনার Firebase প্রোজেক্টে সমস্ত প্রয়োজনীয় API সক্রিয় করা আছে কিনা তা নিশ্চিত করুন।

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

  1. Firebase কনসোলে সাইন ইন করুন এবং তারপরে আপনার ফায়ারবেস প্রজেক্টটি নির্বাচন করুন।

  2. Firebase কনসোলে, AI Services > AI Logic- এ যান।

  3. আপনার প্রোজেক্টের জন্য প্রয়োজনীয় এপিআই ও রিসোর্স সেট আপ করতে সাহায্যকারী একটি নির্দেশিত ওয়ার্কফ্লো চালু করতে 'Get started'- এ ক্লিক করুন।

  4. আপনি Firebase AI Logic SDK-গুলোর সাথে যে 'Gemini API' প্রোভাইডারটি ব্যবহার করতে চান, সেটি নির্বাচন করুন। আপনি চাইলে পরবর্তীতে যেকোনো সময় অন্য API প্রোভাইডারটি সেট আপ করে ব্যবহার করতে পারেন।

    • জেমিনি ডেভেলপার এপিআইবিলিং ঐচ্ছিক (বিনামূল্যের স্পার্ক প্রাইসিং প্ল্যানে উপলব্ধ)
      কনসোলের ওয়ার্কফ্লো আপনার প্রোজেক্টে প্রয়োজনীয় API-গুলো সক্রিয় করবে এবং একটি Gemini API কী তৈরি করবে।
      এই জেমিনি এপিআই কী-টি আপনার অ্যাপের কোডবেসে যোগ করবেন না আরও জানুন।

    • এজেন্ট প্ল্যাটফর্ম জেমিনি এপিআই (পূর্বে ভার্টেক্স এআই)বিলিং আবশ্যক (এর জন্য পে-অ্যাজ-ইউ-গো ব্লেজ প্রাইসিং প্ল্যান প্রয়োজন)
      কনসোলের ওয়ার্কফ্লো আপনার প্রোজেক্টে প্রয়োজনীয় এপিআইগুলো সক্রিয় করবে।

  5. আপনার অ্যাপে লাইব্রেরি ও ইনিশিয়ালাইজেশন আপডেট করতে এই মাইগ্রেশন গাইডটি অনুসরণ করুন।

ধাপ ৩ : আপনার অ্যাপে ব্যবহৃত লাইব্রেরিটি আপডেট করুন।

Firebase AI Logic লাইব্রেরি ব্যবহার করার জন্য আপনার অ্যাপের কোডবেস আপডেট করুন।

সুইফট

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

    • বিকল্প ১ : সমস্ত প্যাকেজ আপডেট করুন: ফাইল > প্যাকেজ > সর্বশেষ প্যাকেজ সংস্করণে আপডেট করুন-এ যান।

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

  2. নিশ্চিত করুন যে Firebase প্যাকেজটিতে এখন v11.13.0 বা তার পরবর্তী সংস্করণ দেখাচ্ছে। যদি তা না দেখায়, তবে যাচাই করুন যে আপনার নির্দিষ্ট করা প্যাকেজ রিকোয়ারমেন্টস (Package Requirements) অনুযায়ী v11.13.0 বা তার পরবর্তী সংস্করণে আপডেট করা যাবে কিনা।

  3. প্রজেক্ট এডিটর-এ আপনার অ্যাপের লক্ষ্য নির্বাচন করুন, এবং তারপর ফ্রেমওয়ার্কস, লাইব্রেরিস, এবং এমবেডেড কন্টেন্ট সেকশনে যান।

  4. নতুন লাইব্রেরিটি যোগ করুন: + বোতামটি নির্বাচন করুন, এবং তারপরে Firebase প্যাকেজ থেকে FirebaseAI যোগ করুন।

  5. আপনার অ্যাপ মাইগ্রেট করা শেষ হলে (এই গাইডের বাকি অংশগুলো দেখুন), পুরোনো লাইব্রেরিটি অবশ্যই মুছে ফেলবেন:
    FirebaseVertexAI-Preview নির্বাচন করুন, এবং তারপর বোতামটি চাপুন।

Kotlin

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

    মনে রাখবেন যে, পুরোনো ডিপেন্ডেন্সিটি ডিলিট করার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

    // BEFORE
    dependencies {
      implementation("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. আপনার অ্যান্ড্রয়েড প্রজেক্টকে গ্রেডল ফাইলের সাথে সিঙ্ক করুন।

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

Java

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

    মনে রাখবেন যে, পুরোনো ডিপেন্ডেন্সিটি ডিলিট করার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

    // BEFORE
    dependencies {
      implementation("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. আপনার অ্যান্ড্রয়েড প্রজেক্টকে গ্রেডল ফাইলের সাথে সিঙ্ক করুন।

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

Web

  1. npm ব্যবহার করে ওয়েবের জন্য Firebase JS SDK-এর সর্বশেষ সংস্করণটি ডাউনলোড করুন:

    npm i firebase@latest

    অথবা

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

    মনে রাখবেন যে, পুরোনো ইম্পোর্টগুলো মুছে ফেলার আগে আপনার অ্যাপের কোডবেস মাইগ্রেট করা আরও সহজ হতে পারে (এই গাইডের বাকি অংশগুলো দেখুন)।

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

Dart

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

    flutter pub add firebase_ai
  2. আপনার ফ্লাটার প্রজেক্টটি পুনর্গঠন করুন:

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

    flutter pub remove firebase_vertexai

ঐক্য

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

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

ধাপ ৪ : আপনার অ্যাপে প্রারম্ভিককরণ আপডেট করুন।

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

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

সুইফট


import FirebaseAILogic

// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

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

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
                        .generativeModel("gemini-3.7-flash")

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
        .generativeModel("gemini-3.7-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, GoogleAIBackend } 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 Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(ai, { model: "gemini-3.7-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 Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
      FirebaseAI.googleAI().generativeModel(model: 'gemini-3.7-flash');

ঐক্য

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

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

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

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

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

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

  • " Vertex AI in Firebase " SDK-এর GA সংস্করণগুলিতে বেশ কিছু পরিবর্তন আনা হয়েছে। Firebase AI Logic SDK ব্যবহার করার জন্যও এই একই পরিবর্তনগুলি আবশ্যক। Firebase AI Logic SDK ব্যবহারের জন্য আপনার কোডে কী কী পরিবর্তন করতে হতে পারে, তা জানতে নিচের তালিকাগুলি পর্যালোচনা করুন।

সকল ভাষা এবং প্ল্যাটফর্মের জন্য আবশ্যক

  • ফাংশন কলিং
    আপনি যদি GA-এর আগে এই ফিচারটি প্রয়োগ করে থাকেন, তাহলে আপনার স্কিমা সংজ্ঞায়িত করার পদ্ধতিতে আপডেট আনতে হবে। আপনার ফাংশন ডিক্লারেশনগুলো কীভাবে লিখতে হয় তা জানতে আমরা আপডেট করা ফাংশন কলিং গাইডটি পর্যালোচনা করার পরামর্শ দিচ্ছি।

  • responseSchema ব্যবহার করে কাঠামোগত আউটপুট (যেমন JSON) তৈরি করা
    আপনি যদি GA-এর আগে এই ফিচারটি প্রয়োগ করে থাকেন, তাহলে আপনার স্কিমা সংজ্ঞায়িত করার পদ্ধতিতে আপডেট আনতে হবে। JSON স্কিমা কীভাবে লিখতে হয় তা জানতে আমরা নতুন স্ট্রাকচার্ড আউটপুট গাইডটি পর্যালোচনা করার পরামর্শ দিচ্ছি।

  • টাইমআউট

    • অনুরোধের জন্য ডিফল্ট টাইমআউট পরিবর্তন করে ১৮০ সেকেন্ড করা হয়েছে।

প্ল্যাটফর্ম বা ভাষার উপর ভিত্তি করে প্রয়োজন

সুইফট

  • গণনা

    • বেশিরভাগ enum টাইপকে স্ট্যাটিক ভেরিয়েবল সহ struct দিয়ে প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি API-কে ব্যাকওয়ার্ড-কম্প্যাটিবল উপায়ে উন্নত করার জন্য আরও বেশি নমনীয়তা প্রদান করে। switch স্টেটমেন্ট ব্যবহার করার সময়, অজানা বা আনহ্যান্ডেলড ভ্যালুগুলো কভার করার জন্য আপনাকে এখন অবশ্যই একটি default: case অন্তর্ভুক্ত করতে হবে, যার মধ্যে ভবিষ্যতে SDK-তে যুক্ত হওয়া নতুন ভ্যালুগুলোও অন্তর্ভুক্ত থাকবে।

    • BlockThreshold এনুমারেশনটির নাম পরিবর্তন করে HarmBlockThreshold রাখা হয়েছে; এই টাইপটি এখন একটি struct

    • নিম্নলিখিত এনুমারেশনগুলি (এখন struct s) থেকে unknown এবং unspecified কেসগুলি সরানো হয়েছে: HarmCategory , HarmBlockThreshold , HarmProbability , BlockReason , এবং FinishReason

    • পূর্ববর্তী সংস্করণের সাথে সামঞ্জস্যপূর্ণভাবে নতুন টাইপ যুক্ত করার সুযোগ দিতে, ModelContent.Part এনুমারেশনটিকে Part নামক একটি প্রোটোকল দ্বারা প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি Content parts বিভাগে আরও বিস্তারিতভাবে বর্ণনা করা হয়েছে।

  • বিষয়বস্তুর অংশ

    • মাঝেমধ্যে ঘটা কম্পাইলার ত্রুটি এড়ানোর জন্য ThrowingPartsRepresentable প্রোটোকলটি সরিয়ে দেওয়া হয়েছে এবং ModelContent এর ইনিশিয়ালাইজারগুলোকে সরল করা হয়েছে। যেসব ইমেজ সঠিকভাবে এনকোড হয় না, সেগুলো generateContent এ ব্যবহার করার সময় এখনও ত্রুটি দেখাবে।

    • Part প্রোটোকল মেনে ModelContent.Part কেসগুলোকে নিম্নলিখিত struct টাইপগুলো দ্বারা প্রতিস্থাপন করা হয়েছে:

      • .text to TextPart
      • .data to InlineDataPart
      • .fileData থেকে FileDataPart
      • .functionCall থেকে FunctionCallPart
      • .functionResponse to FunctionResponsePart
  • ক্ষতির বিভাগ

    • HarmCategory এখন আর SafetySetting টাইপের মধ্যে নেস্টেড রাখা হবে না। আপনি যদি এটিকে SafetySetting.HarmCategory হিসেবে উল্লেখ করে থাকেন, তবে সেটিকে HarmCategory দিয়ে প্রতিস্থাপন করা যাবে।
  • নিরাপত্তা প্রতিক্রিয়া

    • SafetyFeedback টাইপটি সরিয়ে দেওয়া হয়েছে, কারণ এটি কোনো প্রতিক্রিয়ায় ব্যবহৃত হয়নি।
  • উদ্ধৃতি মেটাডেটা

    • CitationMetadata তে citationSources প্রপার্টির নাম পরিবর্তন করে citations রাখা হয়েছে।
  • মোট বিলযোগ্য অক্ষর

    • CountTokensResponse এর totalBillableCharacters প্রপার্টিটিকে ঐচ্ছিক করা হয়েছে, যাতে কোনো ক্যারেক্টার পাঠানো না হলে সেই পরিস্থিতিও প্রতিফলিত হয়।
  • প্রার্থীর প্রতিক্রিয়া

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে CandidateResponse নাম পরিবর্তন করে Candidate রাখা হয়েছে।
  • প্রজন্মের কনফিগারেশন

    • GenerationConfig এর পাবলিক প্রপার্টিগুলোকে internal এ পরিবর্তন করা হয়েছে। ইনিশিয়ালাইজারে এগুলো সবই কনফিগারযোগ্য থাকবে।

Kotlin

  • গণনা

    • enum ক্লাস এবং sealed ক্লাসগুলোকে সাধারণ ক্লাস দিয়ে প্রতিস্থাপন করা হয়েছে। এই পরিবর্তনটি API-কে পশ্চাৎ সামঞ্জস্যপূর্ণ (backward compatible) উপায়ে বিকশিত করার জন্য আরও বেশি নমনীয়তা প্রদান করে।

    • BlockThreshold এনুমারেশনটির নাম পরিবর্তন করে HarmBlockThreshold রাখা হয়েছে।

    • নিম্নলিখিত এনুমারেশনগুলো থেকে মানগুলো মুছে ফেলা হয়েছে: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , এবং FinishReason

  • ব্লব পদ্ধতি

    • যেসব মেথডের নামের অংশ হিসেবে Blob অন্তর্ভুক্ত ছিল, সেগুলোর নাম পরিবর্তন করে InlineData ব্যবহার করা হয়েছে।
  • নিরাপত্তা সেটিংস

    • ফিল্ড method নালযোগ্য করা হয়েছে।
  • সময়কাল শ্রেণী

    • কোটলিনের Duration ক্লাসের সমস্ত ব্যবহার সরিয়ে দিয়ে এর পরিবর্তে long ব্যবহার করা হয়েছে। এই পরিবর্তনটি জাভার সাথে উন্নততর আন্তঃকার্যক্ষমতা প্রদান করে।
  • উদ্ধৃতি মেটাডেটা

    • পূর্বে CitationMetadata তে ঘোষিত সমস্ত ফিল্ডকে Citation নামক একটি নতুন ক্লাসের অধীনে আনা হয়েছে। CitationMetadata এর citations নামক তালিকায় সাইটেশনগুলো পাওয়া যাবে। এই পরিবর্তনটি বিভিন্ন প্ল্যাটফর্মে টাইপগুলোর আরও ভালো সামঞ্জস্য বিধান করে।
  • টোকেন গণনা করুন

    • totalBillableCharacters ফিল্ডটিকে নাল (null) করা হয়েছে।
  • মোট বিলযোগ্য অক্ষর

    • CountTokensResponse এর totalBillableCharacters প্রপার্টিটিকে ঐচ্ছিক করা হয়েছে, যাতে কোনো ক্যারেক্টার পাঠানো না হলে সেই পরিস্থিতিও প্রতিফলিত হয়।
  • একটি মডেল ইনস্ট্যানশিয়েট করা

    • অন্যান্য প্ল্যাটফর্মের সাথে সামঞ্জস্য রাখতে requestOptions প্যারামিটারটিকে প্যারামিটার তালিকার শেষে সরানো হয়েছে।
  • Live API

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

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

Java

  • Enumerations

    • Replaced enum classes and sealed classes with regular classes. This change allows more flexibility for evolving the API in a backward compatible way.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold .

    • Removed values from the following enumerations: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .

  • Blob methods

    • Renamed all methods that included Blob as part of their name to use InlineData instead.
  • Safety settings

    • Changed the field method to be nullable.
  • Duration class

    • Removed all usages of Kotlin's Duration class, and replaced it with long . This change provides better interoperability with Java.
  • Citation metadata

    • Wrapped all the fields previously declared in CitationMetadata into a new class called Citation . Citations can be found in the list called citations in CitationMetadata . This change allows better alignment of types across platforms.
  • Count tokens

    • Changed the field totalBillableCharacters to be nullable.
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Instantiating a model

    • Moved the requestOptions parameter to the end of the parameter list to align with other platforms.
  • Live API

    • Removed UNSPECIFIED value for enum class ResponseModality . Instead use null .

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

  • Changed various Java builder methods to now correctly return the instance of their class, instead of void .

Web

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , BlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .
  • Block reason

    • Changed blockReason in PromptFeedback to be optional.

Changes required only if you're starting to use the Gemini Developer API (instead of the Agent Platform Gemini API (formerly Vertex AI) ):

  • Safety settings

    • Removed usages of the unsupported SafetySetting.method .
  • Inline data

    • Removed usages of the unsupported InlineDataPart.videoMetadata .

Dart

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , HarmProbability , BlockReason , and FinishReason .
  • Data part

    • Renamed DataPart to InlineDataPart , and the static data function to inlineData to align with other platforms.
  • Request options

    • Removed RequestOptions since timeout wasn't functional. It will be re-added in the near future, but it will be moved to the GenerativeModel type to match other platforms.
  • Stop sequences

    • Changed the stopSequences parameter in GenerationConfig to be optional and to default to null instead of an empty array.
  • উদ্ধৃতি

    • Renamed the citationSources property to citations in CitationMetadata . The CitationSource type was renamed to Citation to match other platforms.
  • Unnecessary public types, methods, and properties

    • Removed the following types, methods, and properties which were unintentionally exposed: defaultTimeout , CountTokensResponseFields , parseCountTokensResponse , parseEmbedContentResponse , parseGenerateContentResponse , parseContent , BatchEmbedContentsResponse , ContentEmbedding , EmbedContentRequest , and EmbedContentResponse .
  • Count tokens

    • Removed extra fields from the countTokens function that are no longer necessary. Only contents is needed.
  • Instantiating a model

    • Moved the systemInstruction parameter to the end of the parameter list to align with other platforms.
  • Embedding functionality

    • Removed unsupported embedding functionality ( embedContent and batchEmbedContents ) from the model.

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Possible errors related to migrating

As you're migrating to use the GA version of Firebase AI Logic , you might encounter errors if you haven't completed all of the required changes as described in this migration guide.

403 Error: Requests to this API firebasevertexai.googleapis.com ... are blocked.

If you receive a 403 error that says Requests to this API firebasevertexai.googleapis.com ... are blocked. , it usually means that the Firebase API key in your Firebase configuration file or object doesn't have a required API in its allowlist for the product that you're trying to use.

Make sure that the Firebase API key used by your app has all the required APIs included in the key's "API restrictions" allowlist . For Firebase AI Logic , your Firebase API key needs to have at minimum the Firebase AI Logic API in its allowlist. This API should have been automatically added to your API key's allowlist when you enabled the required APIs in the Firebase console .

You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.


Give feedback about your experience with Firebase AI Logic


,


Firebase AI Logic and its client SDKs were formerly called " Vertex AI in Firebase ". To better reflect our expanded services and features (for example, we now support the Gemini Developer API !), we renamed and repackaged our services into Firebase AI Logic .

To securely access Google's generative AI models directly from your mobile or web apps, you can now choose a " Gemini API " provider — either the long-available Agent Platform Gemini API (formerly Vertex AI) or now the Gemini Developer API . This means that you now have the option to use the Gemini Developer API , which provides a no-cost tier with reasonable rate limits and quotas.

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 : Enable the required APIs.

  • 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.

Step 1 : Choose the best "Gemini API" provider for your app

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

  • The old " Vertex AI in Firebase " SDKs could only use the Agent Platform Gemini API (formerly Vertex AI) .

  • The new Firebase AI Logic SDKs let you choose which " Gemini API " provider you want to call directly from your mobile or web app – either the Gemini Developer API or the Agent Platform Gemini API (formerly Vertex AI) .

Review the differences between using the two Gemini API providers , especially in terms of supported features, pricing, and rate limits. For just one example, the Gemini Developer API doesn't support providing files using Cloud Storage URLs, but it might be a good choice if you want to take advantage of its no-cost tier and reasonable quota.

Step 2 : Enable the required APIs

Ensure that all required APIs are enabled in your Firebase project to use your chosen " Gemini API " provider.

Note that you can have both of API providers enabled in your project at the same time.

  1. Sign into the Firebase console , and then select your Firebase project.

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

  3. Click Get started to launch a guided workflow that helps you set up the required APIs and resources for your project.

  4. Select the "Gemini API" provider that you'd like to use with the Firebase AI Logic SDKs. You can always set up and use the other API provider later, if you'd like.

    • Gemini Developer APIbilling optional (available on the no-cost Spark pricing plan)
      The console's workflow will enable the required APIs and create a Gemini API key in your project.
      Do not add this Gemini API key into your app's codebase. Learn more.

    • Agent Platform Gemini API (formerly Vertex AI)billing required (requires the pay-as-you-go Blaze pricing plan)
      The console's workflow will enable the required APIs in your project.

  5. 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. In Xcode, with your app project open, update your Firebase package to v11.13.0 or later using one of the following options:

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

    • Option 2 : Update Firebase individually: Navigate to the Firebase package in the section called Package Dependencies . Right-click on the Firebase package, and then select Update Package .

  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-Preview , and then press the button.

Kotlin

  1. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle ), replace old dependencies (as applicable) with the following.

    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("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle ), replace old dependencies (as applicable) with the following.

    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("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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.

Web

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

    npm i firebase@latest

    অথবা

    yarn add firebase@latest
  2. Wherever you've imported the library, update your import statements to use firebase/ai instead.

    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-preview";
    
    
    // AFTER
    import { initializeApp } from "firebase/app";
    import { getAI, getGenerativeModel } from "firebase/ai";

Dart

  1. Update to the use the firebase_ai package in your pubspec.yaml file by running the following command from your Flutter project directory:

    flutter pub add firebase_ai
  2. Rebuild your Flutter project:

    flutter run
  3. After you've finished migrating your app (see the remaining sections in this guide), make sure to delete the old package:

    flutter pub remove firebase_vertexai

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Step 4 : Update the initialization in your app

Click your Gemini API provider to view provider-specific content and code on this page.

Update how you initialize the service for your chosen API provider and create a GenerativeModel instance.

সুইফট


import FirebaseAILogic

// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

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

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
                        .generativeModel("gemini-3.7-flash")

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
        .generativeModel("gemini-3.7-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, GoogleAIBackend } 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 Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(ai, { model: "gemini-3.7-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 Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
      FirebaseAI.googleAI().generativeModel(model: 'gemini-3.7-flash');

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Note that depending on the capability you're using, you might not always create a GenerativeModel instance . To stream input and output using the Gemini Live API , create a LiveModel instance.

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

This step describes changes that may be required depending on which features you use.

  • If you use Cloud Storage URLs and you swapped to use the Gemini Developer API in this migration, then you must update your multimodal requests to include files as inline data (or use YouTube URLs for videos).

  • Several changes were introduced for the GA versions of the " Vertex AI in Firebase " SDKs. These same changes are required to use the Firebase AI Logic SDKs. Review the following lists for any changes that you might need to make in your code to accommodate taking up the Firebase AI Logic SDK.

Required for all languages and platforms

  • Function calling
    If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the updated function calling guide to learn how to write your function declarations.

  • Generating structured output (like JSON) using responseSchema
    If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the new structured output guide to learn how to write JSON schemas.

  • টাইমআউট

    • Changed the default timeout for requests to be 180 seconds.

Required based on platform or language

সুইফট

  • Enumerations

    • Replaced most enum types with struct s with static variables. This change allows more flexibility for evolving the API in a backward-compatible way. When using switch statements, you must now include a default: case to cover unknown or unhandled values, including new values that are added to the SDK in the future.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold ; this type is now a struct .

    • Removed unknown and unspecified cases from the following enumerations (now struct s): HarmCategory , HarmBlockThreshold , HarmProbability , BlockReason , and FinishReason .

    • Replaced the enumeration ModelContent.Part with a protocol named Part to allow new types to be added in a backward-compatible way. This change is described in greater detail in the Content parts section.

  • Content parts

    • Removed the ThrowingPartsRepresentable protocol, and simplified the initializers for ModelContent to avoid occasional compiler errors. Images that don't encode properly will still throw errors when being used in generateContent .

    • Replaced the ModelContent.Part cases with the following struct types conforming to the Part protocol:

      • .text to TextPart
      • .data to InlineDataPart
      • .fileData to FileDataPart
      • .functionCall to FunctionCallPart
      • .functionResponse to FunctionResponsePart
  • Harm category

    • Changed the HarmCategory to no longer be nested in the SafetySetting type. If you're referring to it as SafetySetting.HarmCategory , that can be replaced with HarmCategory .
  • Safety feedback

    • Removed the SafetyFeedback type, since it wasn't used in any of the responses.
  • Citation metadata

    • Renamed the citationSources property to citations in CitationMetadata .
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Candidate response

    • Renamed CandidateResponse to Candidate to match other platforms.
  • Generation configuration

    • Changed the public properties of GenerationConfig to internal . They all remain configurable in the initializer.

Kotlin

  • Enumerations

    • Replaced enum classes and sealed classes with regular classes. This change allows more flexibility for evolving the API in a backward compatible way.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold .

    • Removed values from the following enumerations: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .

  • Blob methods

    • Renamed all methods that included Blob as part of their name to use InlineData instead.
  • Safety settings

    • Changed the field method to be nullable.
  • Duration class

    • Removed all usages of Kotlin's Duration class, and replaced it with long . This change provides better interoperability with Java.
  • Citation metadata

    • Wrapped all the fields previously declared in CitationMetadata into a new class called Citation . Citations can be found in the list called citations in CitationMetadata . This change allows better alignment of types across platforms.
  • Count tokens

    • Changed the field totalBillableCharacters to be nullable.
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Instantiating a model

    • Moved the requestOptions parameter to the end of the parameter list to align with other platforms.
  • Live API

    • Removed UNSPECIFIED value for enum class ResponseModality . Instead use null .

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

Java

  • Enumerations

    • Replaced enum classes and sealed classes with regular classes. This change allows more flexibility for evolving the API in a backward compatible way.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold .

    • Removed values from the following enumerations: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .

  • Blob methods

    • Renamed all methods that included Blob as part of their name to use InlineData instead.
  • Safety settings

    • Changed the field method to be nullable.
  • Duration class

    • Removed all usages of Kotlin's Duration class, and replaced it with long . This change provides better interoperability with Java.
  • Citation metadata

    • Wrapped all the fields previously declared in CitationMetadata into a new class called Citation . Citations can be found in the list called citations in CitationMetadata . This change allows better alignment of types across platforms.
  • Count tokens

    • Changed the field totalBillableCharacters to be nullable.
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Instantiating a model

    • Moved the requestOptions parameter to the end of the parameter list to align with other platforms.
  • Live API

    • Removed UNSPECIFIED value for enum class ResponseModality . Instead use null .

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

  • Changed various Java builder methods to now correctly return the instance of their class, instead of void .

Web

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , BlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .
  • Block reason

    • Changed blockReason in PromptFeedback to be optional.

Changes required only if you're starting to use the Gemini Developer API (instead of the Agent Platform Gemini API (formerly Vertex AI) ):

  • Safety settings

    • Removed usages of the unsupported SafetySetting.method .
  • Inline data

    • Removed usages of the unsupported InlineDataPart.videoMetadata .

Dart

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , HarmProbability , BlockReason , and FinishReason .
  • Data part

    • Renamed DataPart to InlineDataPart , and the static data function to inlineData to align with other platforms.
  • Request options

    • Removed RequestOptions since timeout wasn't functional. It will be re-added in the near future, but it will be moved to the GenerativeModel type to match other platforms.
  • Stop sequences

    • Changed the stopSequences parameter in GenerationConfig to be optional and to default to null instead of an empty array.
  • উদ্ধৃতি

    • Renamed the citationSources property to citations in CitationMetadata . The CitationSource type was renamed to Citation to match other platforms.
  • Unnecessary public types, methods, and properties

    • Removed the following types, methods, and properties which were unintentionally exposed: defaultTimeout , CountTokensResponseFields , parseCountTokensResponse , parseEmbedContentResponse , parseGenerateContentResponse , parseContent , BatchEmbedContentsResponse , ContentEmbedding , EmbedContentRequest , and EmbedContentResponse .
  • Count tokens

    • Removed extra fields from the countTokens function that are no longer necessary. Only contents is needed.
  • Instantiating a model

    • Moved the systemInstruction parameter to the end of the parameter list to align with other platforms.
  • Embedding functionality

    • Removed unsupported embedding functionality ( embedContent and batchEmbedContents ) from the model.

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Possible errors related to migrating

As you're migrating to use the GA version of Firebase AI Logic , you might encounter errors if you haven't completed all of the required changes as described in this migration guide.

403 Error: Requests to this API firebasevertexai.googleapis.com ... are blocked.

If you receive a 403 error that says Requests to this API firebasevertexai.googleapis.com ... are blocked. , it usually means that the Firebase API key in your Firebase configuration file or object doesn't have a required API in its allowlist for the product that you're trying to use.

Make sure that the Firebase API key used by your app has all the required APIs included in the key's "API restrictions" allowlist . For Firebase AI Logic , your Firebase API key needs to have at minimum the Firebase AI Logic API in its allowlist. This API should have been automatically added to your API key's allowlist when you enabled the required APIs in the Firebase console .

You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.


Give feedback about your experience with Firebase AI Logic


,


Firebase AI Logic and its client SDKs were formerly called " Vertex AI in Firebase ". To better reflect our expanded services and features (for example, we now support the Gemini Developer API !), we renamed and repackaged our services into Firebase AI Logic .

To securely access Google's generative AI models directly from your mobile or web apps, you can now choose a " Gemini API " provider — either the long-available Agent Platform Gemini API (formerly Vertex AI) or now the Gemini Developer API . This means that you now have the option to use the Gemini Developer API , which provides a no-cost tier with reasonable rate limits and quotas.

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 : Enable the required APIs.

  • 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.

Step 1 : Choose the best "Gemini API" provider for your app

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

  • The old " Vertex AI in Firebase " SDKs could only use the Agent Platform Gemini API (formerly Vertex AI) .

  • The new Firebase AI Logic SDKs let you choose which " Gemini API " provider you want to call directly from your mobile or web app – either the Gemini Developer API or the Agent Platform Gemini API (formerly Vertex AI) .

Review the differences between using the two Gemini API providers , especially in terms of supported features, pricing, and rate limits. For just one example, the Gemini Developer API doesn't support providing files using Cloud Storage URLs, but it might be a good choice if you want to take advantage of its no-cost tier and reasonable quota.

Step 2 : Enable the required APIs

Ensure that all required APIs are enabled in your Firebase project to use your chosen " Gemini API " provider.

Note that you can have both of API providers enabled in your project at the same time.

  1. Sign into the Firebase console , and then select your Firebase project.

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

  3. Click Get started to launch a guided workflow that helps you set up the required APIs and resources for your project.

  4. Select the "Gemini API" provider that you'd like to use with the Firebase AI Logic SDKs. You can always set up and use the other API provider later, if you'd like.

    • Gemini Developer APIbilling optional (available on the no-cost Spark pricing plan)
      The console's workflow will enable the required APIs and create a Gemini API key in your project.
      Do not add this Gemini API key into your app's codebase. Learn more.

    • Agent Platform Gemini API (formerly Vertex AI)billing required (requires the pay-as-you-go Blaze pricing plan)
      The console's workflow will enable the required APIs in your project.

  5. 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. In Xcode, with your app project open, update your Firebase package to v11.13.0 or later using one of the following options:

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

    • Option 2 : Update Firebase individually: Navigate to the Firebase package in the section called Package Dependencies . Right-click on the Firebase package, and then select Update Package .

  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-Preview , and then press the button.

Kotlin

  1. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle ), replace old dependencies (as applicable) with the following.

    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("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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. In your module (app-level) Gradle file (usually <project>/<app-module>/build.gradle.kts or <project>/<app-module>/build.gradle ), replace old dependencies (as applicable) with the following.

    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("com.google.firebase:firebase-vertexai:16.0.0-betaXX")
    }
    
    
    // AFTER
    dependencies {
      // Import the BoM for the Firebase platform
      implementation(platform("com.google.firebase:firebase-bom:34.18.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.

Web

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

    npm i firebase@latest

    অথবা

    yarn add firebase@latest
  2. Wherever you've imported the library, update your import statements to use firebase/ai instead.

    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-preview";
    
    
    // AFTER
    import { initializeApp } from "firebase/app";
    import { getAI, getGenerativeModel } from "firebase/ai";

Dart

  1. Update to the use the firebase_ai package in your pubspec.yaml file by running the following command from your Flutter project directory:

    flutter pub add firebase_ai
  2. Rebuild your Flutter project:

    flutter run
  3. After you've finished migrating your app (see the remaining sections in this guide), make sure to delete the old package:

    flutter pub remove firebase_vertexai

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Step 4 : Update the initialization in your app

Click your Gemini API provider to view provider-specific content and code on this page.

Update how you initialize the service for your chosen API provider and create a GenerativeModel instance.

সুইফট


import FirebaseAILogic

// Initialize the Gemini Developer API backend service
let ai = FirebaseAI.firebaseAI(backend: .googleAI())

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

Kotlin


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
val model = Firebase.ai(backend = GenerativeBackend.googleAI())
                        .generativeModel("gemini-3.7-flash")

Java


// Initialize the Gemini Developer API backend service.
// Create a `GenerativeModel` instance with a model that supports your use case.
GenerativeModel ai = FirebaseAI.getInstance(GenerativeBackend.googleAI())
        .generativeModel("gemini-3.7-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, GoogleAIBackend } 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 Gemini Developer API backend service.
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });

// Create a `GenerativeModel` instance with a model that supports your use case.
const model = getGenerativeModel(ai, { model: "gemini-3.7-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 Gemini Developer API backend service
// Create a `GenerativeModel` instance with a model that supports your use case
final model =
      FirebaseAI.googleAI().generativeModel(model: 'gemini-3.7-flash');

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Note that depending on the capability you're using, you might not always create a GenerativeModel instance . To stream input and output using the Gemini Live API , create a LiveModel instance.

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

This step describes changes that may be required depending on which features you use.

  • If you use Cloud Storage URLs and you swapped to use the Gemini Developer API in this migration, then you must update your multimodal requests to include files as inline data (or use YouTube URLs for videos).

  • Several changes were introduced for the GA versions of the " Vertex AI in Firebase " SDKs. These same changes are required to use the Firebase AI Logic SDKs. Review the following lists for any changes that you might need to make in your code to accommodate taking up the Firebase AI Logic SDK.

Required for all languages and platforms

  • Function calling
    If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the updated function calling guide to learn how to write your function declarations.

  • Generating structured output (like JSON) using responseSchema
    If you implemented this feature before GA, then you'll need to make updates to how you define your schema. We recommend reviewing the new structured output guide to learn how to write JSON schemas.

  • টাইমআউট

    • Changed the default timeout for requests to be 180 seconds.

Required based on platform or language

সুইফট

  • Enumerations

    • Replaced most enum types with struct s with static variables. This change allows more flexibility for evolving the API in a backward-compatible way. When using switch statements, you must now include a default: case to cover unknown or unhandled values, including new values that are added to the SDK in the future.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold ; this type is now a struct .

    • Removed unknown and unspecified cases from the following enumerations (now struct s): HarmCategory , HarmBlockThreshold , HarmProbability , BlockReason , and FinishReason .

    • Replaced the enumeration ModelContent.Part with a protocol named Part to allow new types to be added in a backward-compatible way. This change is described in greater detail in the Content parts section.

  • Content parts

    • Removed the ThrowingPartsRepresentable protocol, and simplified the initializers for ModelContent to avoid occasional compiler errors. Images that don't encode properly will still throw errors when being used in generateContent .

    • Replaced the ModelContent.Part cases with the following struct types conforming to the Part protocol:

      • .text to TextPart
      • .data to InlineDataPart
      • .fileData to FileDataPart
      • .functionCall to FunctionCallPart
      • .functionResponse to FunctionResponsePart
  • Harm category

    • Changed the HarmCategory to no longer be nested in the SafetySetting type. If you're referring to it as SafetySetting.HarmCategory , that can be replaced with HarmCategory .
  • Safety feedback

    • Removed the SafetyFeedback type, since it wasn't used in any of the responses.
  • Citation metadata

    • Renamed the citationSources property to citations in CitationMetadata .
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Candidate response

    • Renamed CandidateResponse to Candidate to match other platforms.
  • Generation configuration

    • Changed the public properties of GenerationConfig to internal . They all remain configurable in the initializer.

Kotlin

  • Enumerations

    • Replaced enum classes and sealed classes with regular classes. This change allows more flexibility for evolving the API in a backward compatible way.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold .

    • Removed values from the following enumerations: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .

  • Blob methods

    • Renamed all methods that included Blob as part of their name to use InlineData instead.
  • Safety settings

    • Changed the field method to be nullable.
  • Duration class

    • Removed all usages of Kotlin's Duration class, and replaced it with long . This change provides better interoperability with Java.
  • Citation metadata

    • Wrapped all the fields previously declared in CitationMetadata into a new class called Citation . Citations can be found in the list called citations in CitationMetadata . This change allows better alignment of types across platforms.
  • Count tokens

    • Changed the field totalBillableCharacters to be nullable.
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Instantiating a model

    • Moved the requestOptions parameter to the end of the parameter list to align with other platforms.
  • Live API

    • Removed UNSPECIFIED value for enum class ResponseModality . Instead use null .

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

Java

  • Enumerations

    • Replaced enum classes and sealed classes with regular classes. This change allows more flexibility for evolving the API in a backward compatible way.

    • Renamed the BlockThreshold enumeration to HarmBlockThreshold .

    • Removed values from the following enumerations: HarmBlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .

  • Blob methods

    • Renamed all methods that included Blob as part of their name to use InlineData instead.
  • Safety settings

    • Changed the field method to be nullable.
  • Duration class

    • Removed all usages of Kotlin's Duration class, and replaced it with long . This change provides better interoperability with Java.
  • Citation metadata

    • Wrapped all the fields previously declared in CitationMetadata into a new class called Citation . Citations can be found in the list called citations in CitationMetadata . This change allows better alignment of types across platforms.
  • Count tokens

    • Changed the field totalBillableCharacters to be nullable.
  • Total billable characters

    • Changed the totalBillableCharacters property in CountTokensResponse to be optional to reflect situations where no characters are sent.
  • Instantiating a model

    • Moved the requestOptions parameter to the end of the parameter list to align with other platforms.
  • Live API

    • Removed UNSPECIFIED value for enum class ResponseModality . Instead use null .

    • Renamed LiveGenerationConfig.setResponseModalities to LiveGenerationConfig.setResponseModality .

    • Removed the LiveContentResponse.Status class, and instead have nested the status fields as properties of LiveContentResponse .

    • Removed the LiveContentResponse class, and instead have provided subclasses of LiveServerMessage that match the responses from the model.

    • Changed LiveModelFutures.connect to return ListenableFuture<LiveSessionFutures> instead of ListenableFuture<LiveSession> .

  • Changed various Java builder methods to now correctly return the instance of their class, instead of void .

Web

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , BlockThreshold , HarmProbability , HarmSeverity , BlockReason , and FinishReason .
  • Block reason

    • Changed blockReason in PromptFeedback to be optional.

Changes required only if you're starting to use the Gemini Developer API (instead of the Agent Platform Gemini API (formerly Vertex AI) ):

  • Safety settings

    • Removed usages of the unsupported SafetySetting.method .
  • Inline data

    • Removed usages of the unsupported InlineDataPart.videoMetadata .

Dart

  • Enumerations

    • Removed values from the following enumerations: HarmCategory , HarmProbability , BlockReason , and FinishReason .
  • Data part

    • Renamed DataPart to InlineDataPart , and the static data function to inlineData to align with other platforms.
  • Request options

    • Removed RequestOptions since timeout wasn't functional. It will be re-added in the near future, but it will be moved to the GenerativeModel type to match other platforms.
  • Stop sequences

    • Changed the stopSequences parameter in GenerationConfig to be optional and to default to null instead of an empty array.
  • উদ্ধৃতি

    • Renamed the citationSources property to citations in CitationMetadata . The CitationSource type was renamed to Citation to match other platforms.
  • Unnecessary public types, methods, and properties

    • Removed the following types, methods, and properties which were unintentionally exposed: defaultTimeout , CountTokensResponseFields , parseCountTokensResponse , parseEmbedContentResponse , parseGenerateContentResponse , parseContent , BatchEmbedContentsResponse , ContentEmbedding , EmbedContentRequest , and EmbedContentResponse .
  • Count tokens

    • Removed extra fields from the countTokens function that are no longer necessary. Only contents is needed.
  • Instantiating a model

    • Moved the systemInstruction parameter to the end of the parameter list to align with other platforms.
  • Embedding functionality

    • Removed unsupported embedding functionality ( embedContent and batchEmbedContents ) from the model.

ঐক্য

Support for Unity wasn't available from " Vertex AI in Firebase ".

Learn how to get started with the Firebase AI Logic SDK for Unity .

Possible errors related to migrating

As you're migrating to use the GA version of Firebase AI Logic , you might encounter errors if you haven't completed all of the required changes as described in this migration guide.

403 Error: Requests to this API firebasevertexai.googleapis.com ... are blocked.

If you receive a 403 error that says Requests to this API firebasevertexai.googleapis.com ... are blocked. , it usually means that the Firebase API key in your Firebase configuration file or object doesn't have a required API in its allowlist for the product that you're trying to use.

Make sure that the Firebase API key used by your app has all the required APIs included in the key's "API restrictions" allowlist . For Firebase AI Logic , your Firebase API key needs to have at minimum the Firebase AI Logic API in its allowlist. This API should have been automatically added to your API key's allowlist when you enabled the required APIs in the Firebase console .

You can view all your API keys in the APIs & Services > Credentials panel in the Google Cloud console.


Give feedback about your experience with Firebase AI Logic