إنشاء تطبيقات وميزات متوافقة مع الأجهزة الجوّالة والويب مستنِدة إلى الذكاء الاصطناعي باستخدام نماذج Gemini وImagen من خلال Firebase AI Logic
يضع Firebase AI Logic في متناولك أحدث نماذج الذكاء الاصطناعي التوليدي من Google، وهي نماذج Gemini وImagen.
إذا كنت بحاجة إلى طلب Gemini API أو Imagen API مباشرةً من تطبيقك على الأجهزة الجوّالة أو تطبيق الويب، بدلاً من جهة الخادم، يمكنك استخدام حِزم تطوير البرامج (SDK) الخاصة بجهة العميل Firebase AI Logic. تم إنشاء حِزم SDK هذه الخاصة بالعملاء خصيصًا لاستخدامها مع تطبيقات الأجهزة الجوّالة وتطبيقات الويب، وهي توفّر خيارات أمان ضد العملاء غير المصرّح لهم، بالإضافة إلى عمليات الدمج مع خدمات Firebase الأخرى.
تتوفّر حِزم تطوير البرامج (SDK) الخاصة بالعملاء هذه في Swift لمنصات Apple وKotlin وJava لنظام التشغيل Android وJavaScript للويب وDart لـ Flutter وUnity.
كان اسم
باستخدام حِزم تطوير البرامج (SDK) الخاصة بالعملاء، يمكنك إضافة ميزة التخصيص المستندة إلى الذكاء الاصطناعي إلى التطبيقات، وإنشاء تجربة دردشة مستندة إلى الذكاء الاصطناعي، وإنشاء عمليات تحسين وأتمتة مستندة إلى الذكاء الاصطناعي، وغير ذلك الكثير.
هل تحتاج إلى مزيد من المرونة أو الدمج من جهة الخادم؟ Genkit هو إطار عمل مفتوح المصدر من Firebase لتطوير الذكاء الاصطناعي المتطوّر من جهة الخادم، ويتيح الوصول على نطاق واسع إلى نماذج من Google وOpenAI وAnthropic وغيرها. يتضمّن هذا الإصدار ميزات أكثر تقدّمًا مستندة إلى الذكاء الاصطناعي وأدوات محلية مخصّصة.
الإمكانات الرئيسية
الإدخال المتعدد الوسائط واللغة الطبيعية
Gemini النماذج هي متعددة الوسائط، لذا يمكن أن تتضمّن الطلبات التي يتم إرسالها إلى Gemini API نصوصًا وصورًا وملفات PDF وفيديوهات وملفات صوتية. يمكن لبعض نماذج Gemini أيضًا إنشاء نتائج متعددة الوسائط.
يمكن توجيه طلبات إلى النموذجين Gemini وImagen باستخدام مدخلات باللغة الطبيعية.
استخدِم Firebase App Check للمساعدة في حماية واجهات برمجة التطبيقات التي تصل إلى نماذج Gemini وImagen من إساءة الاستخدام من قِبل العملاء غير المصرَّح لهم.
توفّر Firebase AI Logic حِزم SDK للعملاء وخدمة وكيل وميزات أخرى تتيح لك الوصول إلى نماذج الذكاء الاصطناعي التوليدي من Google لإنشاء ميزات الذكاء الاصطناعي في تطبيقاتك على الأجهزة الجوّالة وتطبيقات الويب.
دعم نماذج Google ومقدّمي خدمة "Gemini API"
تتوافق هذه الخدمة مع جميع أحدث طُرز Gemini وImagen 3، ويمكنك اختيار مقدّم خدمة "Gemini API" المفضّل لديك للوصول إلى هذه الطُرز. نسمح باستخدام كل من Gemini Developer API وVertex AI Gemini API. تعرَّف على الاختلافات بين استخدام مزوّدَي واجهات برمجة التطبيقات.
وإذا اخترت استخدام Gemini Developer API، يمكنك الاستفادة من "المستوى المجاني" لتتمكّن من البدء والتشغيل بسرعة.
حِزم تطوير البرامج (SDK) الخاصة بالعملاء على الأجهزة الجوّالة والويب
يمكنك إرسال الطلبات إلى النماذج مباشرةً من تطبيقك على الأجهزة الجوّالة أو تطبيق الويب باستخدام حِزم تطوير البرامج (SDK) الخاصة بالعملاء، والمتوفّرة بلغات Swift لمنصات Apple وKotlin وJava لنظام Android وJavaScript للويب وDart لـ Flutter وUnity.Firebase AI Logic
إذا كنت قد أعددت كلا موفّري Gemini API في مشروعك على Firebase، يمكنك التبديل بين موفّري واجهات برمجة التطبيقات من خلال تفعيل واجهة برمجة التطبيقات الأخرى وتغيير بضعة أسطر من رمز الإعداد.
بالإضافة إلى ذلك، تتيح حزمة تطوير البرامج (SDK) الخاصة بالعميل على الويب إمكانية تجريبية للاستدلال المختلط والاستدلال على الجهاز لتطبيقات الويب التي تعمل على Chrome على أجهزة الكمبيوتر. يسمح هذا الإعداد لتطبيقك باستخدام النموذج المتوفّر على الجهاز عندما يكون متاحًا، ولكنّه يعود بسلاسة إلى النموذج المستضاف على السحابة الإلكترونية عند الحاجة.
خدمة الخادم الوكيل
تعمل خدمة الوكيل كبوابة بين العميل ومقدّم خدمة Gemini API الذي اخترته (ونماذج Google). ويوفّر خدمات وعمليات دمج مهمة للتطبيقات على الأجهزة الجوّالة وتطبيقات الويب. على سبيل المثال، يمكنك إعداد Firebase App Check للمساعدة في حماية مزوّد واجهة برمجة التطبيقات الذي اخترته وموارد الخلفية من إساءة الاستخدام من قِبل العملاء غير المصرّح لهم.
ويكون ذلك مهمًا بشكل خاص إذا اخترت استخدام Gemini Developer API، لأنّ خدمة الوكيل وعملية الدمج App Check تضمنان بقاء مفتاح واجهة برمجة التطبيقات Gemini على الخادم وعدم تضمينه في قاعدة رموز تطبيقاتك.
مسار التنفيذ
إعداد مشروعك على Firebase وربط تطبيقك بمنصة Firebase
استخدِم سير العمل الموجَّه في صفحة Firebase AI Logic في وحدة تحكّم Firebase لإعداد مشروعك (بما في ذلك تفعيل واجهات برمجة التطبيقات المطلوبة لموفّر Gemini API الذي اخترته)، وتسجيل تطبيقك في مشروعك على Firebase، ثم إضافة إعدادات Firebase إلى تطبيقك.
تثبيت حزمة تطوير البرامج (SDK) وإعدادها
ثبِّت حزمة تطوير البرامج (SDK) Firebase AI Logic الخاصة بمنصة تطبيقك، ثم ابدأ الخدمة وأنشئ نموذجًا في تطبيقك.
يمكنك تنفيذ عمليات دمج مهمة لتطبيقات الأجهزة الجوّالة وتطبيقات الويب، مثل حماية واجهة برمجة التطبيقات من إساءة الاستخدام باستخدام Firebase App Check واستخدام Firebase Remote Config لتعديل المَعلمات في الرمز البرمجي عن بُعد (مثل اسم النموذج).
الخطوات التالية
بدء الوصول إلى نموذج من تطبيقك على الأجهزة الجوّالة أو تطبيق الويب
تاريخ التعديل الأخير: 2025-08-19 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-19 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["Gemini API using Firebase AI Logic \nplat_ios plat_android plat_web plat_flutter plat_unity \nBuild AI-powered mobile and web apps and features with the Gemini and Imagen models using Firebase AI Logic\n\nFirebase AI Logic gives you access to the latest generative AI models from\nGoogle: the Gemini models and Imagen models.\n\nIf you need to call the Gemini API or Imagen API directly\nfrom your mobile or web app --- rather than server-side --- you can use the\nFirebase AI Logic client SDKs. These client SDKs are built\nspecifically for use with mobile and web apps, offering security options against\nunauthorized clients as well as integrations with other Firebase services.\n\n**These client SDKs are available in\nSwift for Apple platforms, Kotlin \\& Java for Android, JavaScript for web,\nDart for Flutter, and Unity.**\n\n\n| **Firebase AI Logic and its client SDKs were\n| formerly called \"Vertex AI in Firebase\".** In May 2025, we [renamed and\n| repackaged our services into Firebase AI Logic](/docs/ai-logic/faq-and-troubleshooting#renamed-product) to better reflect our expanded services and features --- for example, we now support the Gemini Developer API!\n\n\u003cbr /\u003e\n\nWith these client SDKs, you can add AI personalization to apps, build an AI chat\nexperience, create AI-powered optimizations and automation, and much more!\n\n[Get started](/docs/ai-logic/get-started)\n\n\u003cbr /\u003e\n\n**Need more flexibility or server-side integration?** \n\n[Genkit](https://genkit.dev/) is Firebase's open-source\nframework for sophisticated server-side AI development with broad access to\nmodels from Google, OpenAI, Anthropic, and more. It includes more advanced AI\nfeatures and dedicated local tooling.\n\nKey capabilities\n\n|---------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Multimodal and natural language input | The [Gemini models](/docs/ai-logic/models) are multimodal, so prompts sent to the Gemini API can include text, images, PDFs, video, and audio. Some Gemini models can also generate multimodal *output* . Both the Gemini and Imagen models can be prompted with natural language input. |\n| Growing suite of capabilities | With the SDKs, you can call the Gemini API or Imagen API directly from your mobile or web app to [build AI chat experiences](/docs/ai-logic/chat), [generate images,](/docs/ai-logic/generate-images-imagen) use tools (like [function calling](/docs/ai-logic/function-calling) and [grounding with Google Search](/docs/ai-logic/grounding-google-search)), [stream multimodal input and output (including audio)](/docs/ai-logic/live-api), and more. |\n| Security and abuse prevention for production apps | Use [Firebase App Check](/docs/ai-logic/app-check) to help protect the APIs that access the Gemini and Imagen models from abuse by unauthorized clients. Firebase AI Logic also has [rate limits per user](/docs/ai-logic/faq-and-troubleshooting#rate-limits-per-user) *by default*, and these per-user rate limits are fully configurable. |\n| Robust infrastructure | Take advantage of scalable infrastructure that's built for use with mobile and web apps, like [managing files with Cloud Storage for Firebase](/docs/ai-logic/solutions/cloud-storage), managing structured data with Firebase database offerings (like [Cloud Firestore](/docs/firestore)), and dynamically setting run-time configurations with [Firebase Remote Config](/docs/ai-logic/solutions/remote-config). |\n\nHow does it work?\n\nFirebase AI Logic provides client SDKs, a proxy service, and other features\nwhich allow you to access Google's generative AI models to build AI features in\nyour mobile and web apps.\n\nSupport for Google models and \"Gemini API\" providers\n\nWe support all the latest Gemini models and Imagen 3 models,\nand you choose your preferred \"Gemini API\" provider to access these models.\nWe support both the Gemini Developer API and\nVertex AI Gemini API. Learn about the\n[differences between using the two API providers](/docs/ai-logic/faq-and-troubleshooting#differences-between-gemini-api-providers).\n\nAnd if you choose to use the Gemini Developer API, you can take\nadvantage of their \"free tier\" to get you up and running fast.\n\nMobile \\& web client SDKs\n\nYou send requests to the models directly from your mobile or web app using our\nFirebase AI Logic client SDKs, available in\nSwift for Apple platforms, Kotlin \\& Java for Android, JavaScript for Web,\nDart for Flutter, and Unity.\n\nIf you have both of the Gemini API providers set up in your Firebase\nproject, then you can switch between API providers just by enabling the other\nAPI and changing a few lines of initialization code.\n\nAdditionally, our client SDK for Web offers experimental access to\n[hybrid and on-device inference for web apps](/docs/ai-logic/hybrid-on-device-inference)\nrunning on Chrome on desktop. This configuration allows your app to use the\non-device model when it's available, but fall back seamlessly to the\ncloud-hosted model when needed.\n\nProxy service\n\nOur proxy service acts as a gateway between the client and your chosen\nGemini API provider (and Google's models). It provides services and\nintegrations that are important for mobile and web apps. For example, you can\n[set up Firebase App Check](/docs/ai-logic/app-check) to help protect your\nchosen API provider and your backend resources from abuse by unauthorized\nclients.\n\nThis is particularly critical if you chose to use the\nGemini Developer API because our proxy service and this App Check\nintegration make sure that your Gemini API key stays on the server and\nis *not* embedded in your apps' codebase.\n\nImplementation path\n\n|---|---------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Set up your Firebase project and connect your app to Firebase | Use the guided workflow in the [**Firebase AI Logic** page](https://console.firebase.google.com/project/_/ailogic) of the Firebase console to set up your project (including enabling the required APIs for your chosen Gemini API provider), register your app with your Firebase project, and then add your Firebase configuration to your app. |\n| | Install the SDK and initialize | Install the Firebase AI Logic SDK that's specific to your app's platform, and then initialize the service and create a model instance in your app. |\n| | Send prompt requests to the Gemini and Imagen models | Use the SDKs to send text-only or multimodal prompts to a Gemini model to generate [text and code](/docs/ai-logic/generate-text), [structured output (like JSON)](/docs/ai-logic/generate-structured-output) and [images](/docs/ai-logic/generate-images-gemini). Alternatively, you can also prompt an Imagen model to [generate images](/docs/ai-logic/generate-images-imagen). Build richer experiences with [multi-turn chat](/docs/ai-logic/chat), [bidirectional streaming of text and audio](/docs/ai-logic/live-api), and [function calling](/docs/ai-logic/function-calling). |\n| | Prepare for production | Implement important integrations for mobile and web apps, like protecting the API from abuse with [Firebase App Check](/docs/ai-logic/app-check) and using [Firebase Remote Config](/docs/ai-logic/solutions/remote-config) to update parameters in your code remotely (like model name). |\n\nNext steps\n\nGet started with accessing a model from your mobile or web app\n\n[Go to Getting Started guide](/docs/ai-logic/get-started)\n\n\nLearn more about the supported models Learn about the [models available for various use cases](/docs/ai-logic/models) and their [quotas](/docs/ai-logic/quotas) and [pricing](/docs/ai-logic/pricing).\n\n\u003cbr /\u003e"]]