จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Gemini API กำลังใช้ Firebase AI Logic
plat_ios
plat_android
plat_web
plat_flutter
plat_unity
สร้างแอปและฟีเจอร์บนอุปกรณ์เคลื่อนที่และเว็บที่ทำงานด้วยระบบ AI ด้วยโมเดล Gemini และ Imagen โดยใช้ Firebase AI Logic
Firebase AI Logic ช่วยให้คุณเข้าถึงโมเดล Generative AI ล่าสุดจาก Google ได้แก่ โมเดล Gemini และโมเดล Imagen
หากต้องการเรียกใช้ Gemini API หรือ Imagen API โดยตรง
จากแอปบนอุปกรณ์เคลื่อนที่หรือเว็บแอปแทนที่จะใช้ฝั่งเซิร์ฟเวอร์ คุณสามารถใช้
Firebase AI Logic SDK ของไคลเอ็นต์ SDK ไคลเอ็นต์เหล่านี้สร้างขึ้น
เพื่อใช้กับแอปบนอุปกรณ์เคลื่อนที่และเว็บแอปโดยเฉพาะ โดยมีตัวเลือกความปลอดภัยเพื่อป้องกัน
ไคลเอ็นต์ที่ไม่ได้รับอนุญาต รวมถึงการผสานรวมกับบริการอื่นๆ ของ Firebase
SDK ไคลเอ็นต์เหล่านี้พร้อมใช้งานใน
Swift สำหรับแพลตฟอร์ม Apple, Kotlin และ Java สำหรับ Android, JavaScript สำหรับเว็บ,
Dart สำหรับ Flutter และ Unity
SDK ของไคลเอ็นต์เหล่านี้ช่วยให้คุณเพิ่มการปรับเปลี่ยนในแบบของคุณด้วย AI ลงในแอป สร้างประสบการณ์แชทด้วย AI
สร้างการเพิ่มประสิทธิภาพและการทำงานอัตโนมัติที่ทำงานด้วยระบบ AI และอื่นๆ อีกมากมายได้
เริ่มต้นใช้งาน
หากต้องการความยืดหยุ่นเพิ่มเติมหรือการผสานรวมฝั่งเซิร์ฟเวอร์
Genkit คือเฟรมเวิร์กโอเพนซอร์สของ Firebase
สำหรับการพัฒนา AI ฝั่งเซิร์ฟเวอร์ที่ซับซ้อนพร้อมการเข้าถึงโมเดลจาก Google, OpenAI, Anthropic และอื่นๆ ในวงกว้าง ซึ่งรวมถึงฟีเจอร์ AI ขั้นสูงเพิ่มเติม
และเครื่องมือเฉพาะในพื้นที่
ความสามารถหลัก
วิธีการทำงาน
Firebase AI Logic มี SDK ของไคลเอ็นต์ บริการพร็อกซี และฟีเจอร์อื่นๆ
ซึ่งช่วยให้คุณเข้าถึงโมเดล Generative AI ของ Google เพื่อสร้างฟีเจอร์ AI ใน
แอปบนอุปกรณ์เคลื่อนที่และเว็บแอปได้
การสนับสนุนสำหรับโมเดลของ Google และผู้ให้บริการ "Gemini API"
เรารองรับโมเดล Gemini และโมเดล Imagen 3 รุ่นล่าสุดทั้งหมด
และคุณเลือกผู้ให้บริการ "Gemini API" ที่ต้องการเพื่อเข้าถึงโมเดลเหล่านี้ได้
เราสนับสนุนทั้ง Gemini Developer API และ
Vertex AI Gemini API ดูข้อมูลเกี่ยวกับความแตกต่างระหว่างการใช้ผู้ให้บริการ API ทั้ง 2 ราย
และหากเลือกใช้ Gemini Developer API คุณจะใช้ประโยชน์จาก "ระดับฟรี" เพื่อให้พร้อมใช้งานได้อย่างรวดเร็ว
SDK ของไคลเอ็นต์บนอุปกรณ์เคลื่อนที่และเว็บ
คุณส่งคำขอไปยังโมเดลได้โดยตรงจากแอปบนอุปกรณ์เคลื่อนที่หรือเว็บแอปโดยใช้
Firebase AI Logic SDK ของไคลเอ็นต์ ซึ่งพร้อมใช้งานใน
Swift สำหรับแพลตฟอร์ม Apple, Kotlin และ Java สำหรับ Android, JavaScript สำหรับเว็บ
Dart สำหรับ Flutter และ Unity
หากคุณตั้งค่าทั้ง 2 Gemini APIผู้ให้บริการในโปรเจ็กต์ Firebase
คุณจะสลับระหว่างผู้ให้บริการ API ได้เพียงแค่เปิดใช้ API อื่น
และเปลี่ยนโค้ดการเริ่มต้นเพียงไม่กี่บรรทัด
นอกจากนี้ SDK ไคลเอ็นต์สำหรับเว็บยังให้สิทธิ์เข้าถึงเวอร์ชันทดลองของการอนุมานแบบไฮบริดและในอุปกรณ์สำหรับเว็บแอป
ที่ทำงานใน Chrome บนเดสก์ท็อปด้วย การกำหนดค่านี้ช่วยให้แอปใช้โมเดลในอุปกรณ์ได้เมื่อพร้อมใช้งาน แต่จะเปลี่ยนไปใช้โมเดลที่โฮสต์ในระบบคลาวด์ได้อย่างราบรื่นเมื่อจำเป็น
บริการพร็อกซี
บริการพร็อกซีของเราทำหน้าที่เป็นเกตเวย์ระหว่างไคลเอ็นต์กับGemini APIผู้ให้บริการที่คุณเลือก (และโมเดลของ Google) โดยมีบริการและการผสานรวมที่สำคัญสำหรับแอปบนอุปกรณ์เคลื่อนที่และเว็บ เช่น คุณสามารถตั้งค่า Firebase App Check เพื่อช่วยปกป้องผู้ให้บริการ API ที่คุณเลือกและทรัพยากรแบ็กเอนด์จากการละเมิดโดยไคลเอ็นต์ที่ไม่ได้รับอนุญาต
ซึ่งมีความสำคัญอย่างยิ่งหากคุณเลือกใช้
Gemini Developer API เนื่องจากบริการพร็อกซีและการผสานรวม App Check
นี้จะช่วยให้มั่นใจได้ว่าคีย์ API ของ Gemini จะยังคงอยู่ในเซิร์ฟเวอร์และไม่ได้ฝังอยู่ในโค้ดเบสของแอป
เส้นทางการติดตั้งใช้งาน
|
ตั้งค่าโปรเจ็กต์ Firebase และเชื่อมต่อแอปกับ Firebase |
ใช้เวิร์กโฟลว์แบบมีคำแนะนำในหน้าFirebase AI Logic ของ
Firebase คอนโซลเพื่อตั้งค่าโปรเจ็กต์ (รวมถึงการเปิดใช้
API ที่จำเป็นสำหรับผู้ให้บริการ Gemini API ที่คุณเลือก) ลงทะเบียนแอปกับ
โปรเจ็กต์ Firebase แล้วเพิ่มการกำหนดค่า Firebase ลงใน
แอป
|
|
ติดตั้ง SDK และเริ่มต้น |
ติดตั้ง SDK Firebase AI Logic ที่เฉพาะเจาะจงสำหรับแพลตฟอร์มของแอป
จากนั้นเริ่มต้นบริการและสร้างอินสแตนซ์โมเดลในแอป
|
|
ส่งคำขอพรอมต์ไปยังโมเดล Gemini และ Imagen |
ใช้ SDK เพื่อส่งพรอมต์ที่เป็นข้อความเท่านั้นหรือพรอมต์หลายรูปแบบไปยังGemini
โมเดลเพื่อสร้าง
ข้อความและโค้ด
เอาต์พุตที่มีโครงสร้าง (เช่น JSON)
และ
รูปภาพ
หรือคุณจะป้อนพรอมต์Imagenโมเดลให้
สร้างรูปภาพก็ได้
สร้างประสบการณ์การใช้งานที่สมบูรณ์ยิ่งขึ้นด้วย
การแชทแบบหลายรอบ
การสตรีมข้อความและเสียงแบบสองทิศทาง
และ
การเรียกใช้ฟังก์ชัน
|
|
เตรียมพร้อมสำหรับเวอร์ชันที่ใช้งานจริง |
ใช้การผสานรวมที่สำคัญสำหรับแอปบนอุปกรณ์เคลื่อนที่และเว็บ เช่น
การปกป้อง API จากการละเมิดด้วย
Firebase App Check
และการใช้
Firebase Remote Config
เพื่ออัปเดตพารามิเตอร์ในโค้ดจากระยะไกล (เช่น ชื่อโมเดล)
|
ขั้นตอนถัดไป
เริ่มต้นใช้งานด้วยการเข้าถึงโมเดลจากแอปบนอุปกรณ์เคลื่อนที่หรือเว็บแอป
ไปที่คู่มือเริ่มต้นใช้งาน
ดูข้อมูลเพิ่มเติมเกี่ยวกับโมเดลที่รองรับ
ดูข้อมูลเกี่ยวกับ
โมเดลที่พร้อมใช้งานสำหรับกรณีการใช้งานต่างๆ
รวมถึง
โควต้าและ
ราคา
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-19 UTC
[null,null,["อัปเดตล่าสุด 2025-08-19 UTC"],[],[],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"]]