تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
توفّر مجموعتا نماذج Gemini Pro وGemini Flash لمطوّري تطبيقات Android
إمكانات الذكاء الاصطناعي المتعدّد الوسائط، وتنفيذ الاستنتاج في السحابة الإلكترونية ومعالجة إدخالات الصور،
والصوت، والفيديوهات، والنصوص في تطبيقات Android.
Gemini Pro: Gemini 2.5 Pro هو نموذج التفكير الأكثر تطورًا من Google، وهو قادر على التفكير في المشاكل المعقدة في الرموز البرمجية والرياضيات والعلوم والتكنولوجيا والهندسة والرياضيات (STEM)، بالإضافة إلى تحليل مجموعات البيانات الكبيرة وقواعد الرموز البرمجية والمستندات باستخدام سياق طويل.
Gemini Flash: توفّر نماذج Gemini Flash ميزات جيل جديد و
إمكانات محسّنة، بما في ذلك سرعة فائقة واستخدام أدوات مدمجة وقدرة استيعاب مليون
رمز مميّز.
منطق الذكاء الاصطناعي في Firebase
يتيح Firebase AI Logic للمطوّرين إضافة ميزات الذكاء الاصطناعي التوليدي من Google مباشرةً وبأمان إلى تطبيقاتهم، ما يسهّل عملية التطوير، ويقدّم أدوات وعمليات دمج المنتجات للاستعداد للإصدار الناجح. وتوفّر هذه الحزمة لبرامج العميل
حِزم SDK لنظام التشغيل Android من أجل دمج واجهات برمجة تطبيقات Gemini مباشرةً والاتصال بها من رمز العميل،
ما يسهّل عملية التطوير من خلال إزالة الحاجة إلى واجهة خلفية.
موفّرو واجهات برمجة التطبيقات
يتيح لك Firebase AI Logic استخدام موفّري Google Gemini API التاليين:
Developer API في Gemini وAI Gemini API في Vertex.
الشكل 1.
بنية دمج منطق الذكاء الاصطناعي في Firebase
في ما يلي الاختلافات الأساسية لكل موفّر واجهة برمجة التطبيقات:
وهو مثالي للمطوّرين الذين يستخدمون منظومة Vertex AI/Google Cloud المتكاملة.
يمكنك تكرار الطلبات وتجربتها، وحتى الحصول على مقتطفات من الرموز البرمجية باستخدام
Vertex AI Studio.
يعتمد اختيار مزوّد واجهة برمجة التطبيقات المناسب لتطبيقك على
قيود نشاطك التجاري والتقنية، وعلى مدى إلمامك بمنصّة Vertex AI ومنظومة Google Cloud المتكاملة. على معظم مطوّري تطبيقات Android الذين بدأوا للتو في دمج Gemini
Pro أو Gemini Flash استخدام Gemini Developer API.
يتم التبديل بين مقدّمي الخدمات من خلال تغيير المَعلمة في ملف بدء برمجة النموذج:
Kotlin
// For Vertex AI, use `backend = GenerativeBackend.vertexAI()`valmodel=Firebase.ai(backend=GenerativeBackend.googleAI()).generativeModel("gemini-2.5-flash")valresponse=model.generateContent("Write a story about a magic backpack");valoutput=response.text
Java
// For Vertex AI, use `backend = GenerativeBackend.vertexAI()`GenerativeModelfirebaseAI=FirebaseAI.getInstance(GenerativeBackend.googleAI()).generativeModel("gemini-2.5-flash");// Use the GenerativeModelFutures Java compatibility layer which offers// support for ListenableFuture and Publisher APIsGenerativeModelFuturesmodel=GenerativeModelFutures.from(firebaseAI);Contentprompt=newContent.Builder().addText("Write a story about a magic backpack.").build();ListenableFuture<GenerateContentResponse>response=model.generateContent(prompt);Futures.addCallback(response,newFutureCallback<GenerateContentResponse>(){@OverridepublicvoidonSuccess(GenerateContentResponseresult){StringresultText=result.getText();[...]}@OverridepublicvoidonFailure(Throwablet){t.printStackTrace();}},executor);
بالإضافة إلى إمكانية الوصول إلى Gemini API، يوفّر Firebase AI Logic مجموعة من
الخدمات لتبسيط عملية نشر الميزات المزوّدة بالذكاء الاصطناعي في تطبيقك والاستعداد
للنشر:
فحص التطبيق
تحمي ميزة فحص التطبيقات من Firebase الخلفيات في التطبيقات من إساءة الاستخدام من خلال
التأكّد من أنّ العملاء المعتمَدين فقط هم من يمكنهم الوصول إلى الموارد. ويمكن دمجها مع خدمات Google (بما في ذلك Firebase وGoogle Cloud) وخدمات الخلفية المخصّصة. يستخدم تطبيق "فحص التطبيق" Play Integrity للتحقّق من أنّ الطلبات تأتي من التطبيق الموثوق فيه
وجهاز لم يتم التلاعب به.
أداة الإعداد عن بُعد
بدلاً من الترميز الثابت لاسم النموذج في تطبيقك، ننصحك باستخدامvarivariable يتم التحكّم فيه من خلال الخادم باستخدام الإعداد عن بُعد في Firebase. يتيح لك ذلك تعديل النموذج الذي يستخدمه تطبيقك بشكل ديناميكي بدون الحاجة إلى نشر إصدار جديد من تطبيقك أو مطالبة المستخدمين بتثبيت إصدار جديد. يمكنك
أيضًا استخدام ميزة "الإعداد عن بُعد" لاختبار A/B للنماذج والطلبات.
مراقبة الذكاء الاصطناعي
لفهم مستوى أداء الميزات المزوّدة بالذكاء الاصطناعي، يمكنك استخدام لوحة بيانات monitoring
للذكاء الاصطناعي ضمن وحدة تحكّم Firebase. ستحصل على
إحصاءات قيّمة عن أنماط الاستخدام ومقاييس الأداء ومعلومات debugging
لطلبات البيانات من واجهة برمجة التطبيقات Gemini API.
نقل البيانات إلى Firebase AI Logic
إذا كنت تستخدِم حزمة تطوير البرامج (SDK) لـ Vertex AI في Firebase في تطبيقك، يمكنك الاطّلاع على دليل نقل البيانات.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-17 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-17 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Gemini AI models\n\nThe Gemini Pro and Gemini Flash model families offer Android developers\nmultimodal AI capabilities, running inference in the cloud and processing image,\naudio, video, and text inputs in Android apps.\n\n- **Gemini Pro**: Gemini 2.5 Pro is Google's state-of-the-art thinking model, capable of reasoning over complex problems in code, math, and STEM, as well as analyzing large datasets, codebases, and documents using long context.\n- **Gemini Flash**: The Gemini Flash models deliver next-gen features and improved capabilities, including superior speed, built-in tool use, and a 1M token context window.\n\n| **Note:** This document covers the cloud-based Gemini AI models. For on-device inference, [check out the Gemini Nano documentation](/ai/gemini-nano).\n\nFirebase AI Logic\n-----------------\n\nFirebase AI Logic enables developers to securely and directly add Google's\ngenerative AI into their apps simplifying development, and offers tools and\nproduct integrations for successful production readiness. It provides client\nAndroid SDKs to directly integrate and call Gemini APIs from client code,\nsimplifying development by eliminating the need for a backend.\n\nAPI providers\n-------------\n\nFirebase AI Logic lets you use the following Google Gemini API providers:\nGemini *Developer API* and Vertex *AI Gemini API*.\n**Figure 1.** Firebase AI Logic integration architecture.\n\nHere are the primary differences for each API provider:\n\n[**Gemini Developer API**](/ai/gemini/developer-api):\n\n- Get started at no-cost with a generous free tier without payment information required.\n- Optionally upgrade to the paid tier of the Gemini Developer API to scale as your user base grows.\n- Iterate and experiment with prompts and even get code snippets using [Google AI Studio](https://aistudio.google.com/).\n\n[**Vertex AI Gemini API**](/ai/vertex-ai-firebase):\n\n- Granular control over [where you access the model](https://cloud.google.com/compute/docs/regions-zones).\n- Ideal for developers already embedded in the Vertex AI/Google Cloud ecosystem.\n- Iterate and experiment with prompts and even get code snippets using [Vertex AI Studio](https://cloud.google.com/vertex-ai/generative-ai/docs/start/quickstarts/quickstart).\n\nSelecting the appropriate API provider for your application is based on your\nbusiness and technical constraints, and familiarity with the Vertex AI and\nGoogle Cloud ecosystem. Most Android developers just getting started with Gemini\nPro or Gemini Flash integrations should begin with the Gemini Developer API.\nSwitching between providers is done by changing the parameter in the model\nconstructor: \n\n### Kotlin\n\n // For Vertex AI, use `backend = GenerativeBackend.vertexAI()`\n val model = Firebase.ai(backend = GenerativeBackend.googleAI())\n .generativeModel(\"gemini-2.5-flash\")\n\n val response = model.generateContent(\"Write a story about a magic backpack\");\n val output = response.text\n\n### Java\n\n // For Vertex AI, use `backend = GenerativeBackend.vertexAI()`\n GenerativeModel firebaseAI = FirebaseAI.getInstance(GenerativeBackend.googleAI())\n .generativeModel(\"gemini-2.5-flash\");\n\n // Use the GenerativeModelFutures Java compatibility layer which offers\n // support for ListenableFuture and Publisher APIs\n GenerativeModelFutures model = GenerativeModelFutures.from(firebaseAI);\n\n Content prompt = new Content.Builder()\n .addText(\"Write a story about a magic backpack.\")\n .build();\n\n ListenableFuture\u003cGenerateContentResponse\u003e response = model.generateContent(prompt);\n Futures.addCallback(response, new FutureCallback\u003cGenerateContentResponse\u003e() {\n @Override\n public void onSuccess(GenerateContentResponse result) {\n String resultText = result.getText();\n [...]\n }\n\n @Override\n public void onFailure(Throwable t) {\n t.printStackTrace();\n }\n }, executor);\n\nSee the full [list of available generative AI models](https://firebase.google.com/docs/vertex-ai/models) supported\nby Firebase AI Logic client SDKs.\n\nFirebase services\n-----------------\n\nIn addition to access to the Gemini API, Firebase AI Logic offers a set of\nservices to simplify the deployment of AI-enabled features to your app and get\nready for production:\n\n### App Check\n\n[Firebase App Check](https://firebase.google.com/docs/app-check) safeguards app backends from abuse by\nensuring only authorized clients access resources. It integrates with Google\nservices (including Firebase and Google Cloud) and custom backends. App Check\nuses [Play Integrity](/google/play/integrity) to verify that requests originate from the authentic\napp and an untampered device.\n\n### Remote Config\n\nInstead of hardcoding the model name in your app, we recommend using a\nserver-controlled variable using [Firebase Remote Config](https://firebase.google.com/docs/remote-config). This\nlets you dynamically update the model your app uses without having to deploy a\nnew version of your app or require your users to pick up a new version. You can\nalso use Remote Config to [A/B test](https://firebase.google.com/docs/ab-testing/abtest-config) models and prompts.\n\n### AI monitoring\n\nTo understand how your AI-enabled features are performing you can use the [AI\nmonitoring dashboard](https://firebase.google.com/docs/vertex-ai/monitoring) within the Firebase console. You'll get\nvaluable insights into usage patterns, performance metrics, and debugging\ninformation for your Gemini API calls.\n\nMigrate to Firebase AI Logic\n----------------------------\n\nIf you're already using the Vertex AI in Firebase SDK in your app, read the\n[migration guide](https://firebase.google.com/docs/vertex-ai/migrate-to-latest-sdk)."]]