با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Gemini API با استفاده از Firebase AI Logic
plat_ios
plat_android
plat_web
plat_flutter
plat_unity
با استفاده از Firebase AI Logic ، اپلیکیشنها و ویژگیهای موبایل و وب مبتنی بر هوش مصنوعی را با مدلهای Gemini و Imagen بسازید.
Firebase AI Logic به شما امکان دسترسی به جدیدترین مدلهای هوش مصنوعی مولد Google را میدهد: مدلهای Gemini و مدلهای Imagen .
اگر نیاز دارید که Gemini API یا Imagen API مستقیماً از طریق تلفن همراه یا برنامه وب خود - به جای سمت سرور - فراخوانی کنید، می توانید از SDK های مشتری Firebase AI Logic استفاده کنید. این SDK های مشتری به طور خاص برای استفاده با برنامه های تلفن همراه و وب ساخته شده اند و گزینه های امنیتی را در برابر مشتریان غیرمجاز و همچنین ادغام با سایر سرویس های Firebase ارائه می دهند.
این SDK های مشتری در سوئیفت برای پلتفرم های اپل، کاتلین و جاوا برای اندروید، جاوا اسکریپت برای وب، دارت برای فلاتر و یونیتی در دسترس هستند.
با این SDK های مشتری، می توانید شخصی سازی هوش مصنوعی را به برنامه ها اضافه کنید، تجربه چت هوش مصنوعی ایجاد کنید، بهینه سازی ها و اتوماسیون های مبتنی بر هوش مصنوعی را ایجاد کنید، و خیلی چیزهای دیگر!
شروع کنید
به انعطاف پذیری بیشتر یا یکپارچه سازی سمت سرور نیاز دارید؟
Genkit چارچوب منبع باز Firebase برای توسعه پیشرفته هوش مصنوعی سمت سرور با دسترسی گسترده به مدلهای Google، OpenAI، Anthropic و غیره است. این شامل ویژگیهای پیشرفتهتر هوش مصنوعی و ابزارهای محلی اختصاصی است.
قابلیت های کلیدی
چگونه کار می کند؟
Firebase AI Logic SDK های مشتری، یک سرویس پروکسی و سایر ویژگی ها را ارائه می دهد که به شما امکان می دهد به مدل های هوش مصنوعی مولد Google برای ایجاد ویژگی های هوش مصنوعی در برنامه های تلفن همراه و وب خود دسترسی داشته باشید.
پشتیبانی از مدل های Google و ارائه دهندگان " Gemini API ".
ما از آخرین مدلهای Gemini و مدلهای Imagen 3 پشتیبانی میکنیم و شما ارائهدهنده « جمینی API » دلخواه خود را برای دسترسی به این مدلها انتخاب میکنید. ما هم از Gemini Developer API و هم Vertex AI Gemini API پشتیبانی می کنیم. در مورد تفاوت بین استفاده از دو ارائه دهنده API بیاموزید.
و اگر میخواهید از Gemini Developer API استفاده کنید، میتوانید از «سطح رایگان» آنها برای راهاندازی سریع و راهاندازی سریع آنها استفاده کنید.
SDKهای موبایل و کلاینت وب
شما درخواستها را مستقیماً از طریق تلفن همراه یا برنامه وب خود با استفاده از SDK مشتری هوش مصنوعی Firebase ما، که در Swift برای پلتفرمهای Apple، Kotlin و Java برای Android، JavaScript برای Web، Dart برای Flutter و Unity موجود است، به مدلها ارسال میکنید.
اگر هر دو ارائهدهنده API Gemini را در پروژه Firebase خود تنظیم کردهاید، میتوانید تنها با فعال کردن API دیگر و تغییر چند خط کد اولیه، بین ارائهدهندگان API جابهجا شوید.
علاوه بر این، SDK مشتری ما برای وب، دسترسی آزمایشی به استنتاج ترکیبی و درون دستگاه را برای برنامههای وب در حال اجرا در Chrome روی دسکتاپ ارائه میدهد. این پیکربندی به برنامه شما اجازه میدهد تا در صورت موجود بودن از مدل روی دستگاه استفاده کند، اما در صورت نیاز به مدل میزبان ابری بازگردد.
سرویس پروکسی
سرویس پروکسی ما به عنوان دروازه ای بین مشتری و ارائه دهنده Gemini API انتخابی شما (و مدل های Google) عمل می کند. خدمات و ادغام هایی را ارائه می دهد که برای برنامه های موبایل و وب مهم هستند. به عنوان مثال، میتوانید Firebase App Check راهاندازی کنید تا به محافظت از ارائهدهنده API انتخابی و منابع باطن خود در برابر سوءاستفاده توسط مشتریان غیرمجاز کمک کند.
این امر به ویژه در صورت استفاده از Gemini Developer API بسیار مهم است زیرا سرویس پروکسی ما و ادغام این App Check مطمئن می شوند که کلید Gemini API شما روی سرور باقی می ماند و در پایگاه کد برنامه های شما جاسازی نمی شود.
مسیر پیاده سازی
| پروژه Firebase خود را راه اندازی کنید و برنامه خود را به Firebase متصل کنید | از گردش کار هدایت شده در صفحه منطق هوش مصنوعی Firebase در کنسول Firebase برای راه اندازی پروژه خود استفاده کنید (از جمله فعال کردن API های مورد نیاز برای ارائه دهنده API Gemini انتخابی)، برنامه خود را با پروژه Firebase خود ثبت کنید و سپس پیکربندی Firebase خود را به برنامه خود اضافه کنید. |
| SDK را نصب کنید و مقداردهی اولیه کنید | Firebase AI Logic SDK را که مخصوص پلتفرم برنامه شما است نصب کنید و سپس سرویس را مقداردهی اولیه کنید و یک نمونه مدل در برنامه خود ایجاد کنید. |
| درخواست های فوری را به مدل های Gemini و Imagen ارسال کنید | از SDK ها برای ارسال پیام های متنی یا چندوجهی به مدل Gemini برای تولید متن و کد ، خروجی ساختاریافته (مانند JSON) و تصاویر استفاده کنید. همچنین، میتوانید از یک مدل Imagen برای تولید تصاویر درخواست کنید. با چت چند نوبتی ، پخش متن و صوت دو طرفه و فراخوانی عملکرد ، تجربیات غنی تری بسازید. |
| برای تولید آماده شود | ادغامهای مهمی را برای برنامههای تلفن همراه و وب اجرا کنید، مانند محافظت از API در برابر سوء استفاده با Firebase App Check و استفاده از Firebase Remote Config برای بهروزرسانی پارامترهای کدتان از راه دور (مانند نام مدل). |
مراحل بعدی
با دسترسی به یک مدل از تلفن همراه یا برنامه وب خود شروع کنید
به راهنمای شروع کار بروید
درباره مدل های پشتیبانی شده بیشتر بدانید
در مورد
مدل های موجود برای موارد استفاده مختلف و
سهمیه ها و
قیمت آنها اطلاعات کسب کنید.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-19 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 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"]]