모바일 또는 웹 앱에서 직접 API를 호출하면 (예: 생성형 AI 모델에 대한 액세스를 허용하는 API) 승인되지 않은 클라이언트가 API를 악용할 수 있습니다. 이러한 API를 보호하려면 Firebase App Check를 사용하여 모든 수신 API 호출이 실제 앱에서 이루어지는지 확인할 수 있습니다.
Firebase AI Logic는 Firebase App Check와 통합하고 모바일 및 웹 앱에서 호출하는 생성형 AI 모델 API를 보호할 수 있는 프록시 게이트웨이를 제공합니다. Firebase AI Logic SDK와 함께 App Check을 사용하면 모든 구성을 지원합니다.
'Gemini API' 제공업체인 Gemini Developer API와 Vertex AI Gemini API를 모두 보호합니다.
Gemini 모델과 Imagen 모델 모두 지원되는 모든 모델을 보호합니다.
App Check 작동 방식에 대한 간략한 요약
App Check를 사용하면 앱을 실행하는 기기는 다음 중 하나 또는 둘 모두를 확인하는 앱 또는 기기 증명 제공자를 사용합니다.
요청이 인증된 앱에서 발생함
요청이 변조되지 않은 인증된 기기에서 발생함
이 증명은 앱이 Firebase AI Logic SDK를 사용하여 수행하는 모든 요청에 연결됩니다. App Check 적용을 사용 설정하면 유효한 증명이 없는 클라이언트의 요청이 거부되며 승인하지 않은 앱이나 플랫폼에서 발생한 요청도 거부됩니다.
App Check를 설정할 때는 향상된 보호 기능(재생 보호라고 함)을 준비하는 것이 좋습니다.
인스턴스화하는 동안 앱에서 useLimitedUseAppCheckTokens 매개변수를 true로 설정하여 사용 빈도가 제한된 토큰의 사용을 사용 설정합니다.
Swift
// ...// During instantiation, enable usage of limited-use tokensletai=FirebaseAI.firebaseAI(backend:.googleAI(),useLimitedUseAppCheckTokens:true)// ...
Kotlin
// ...// During instantiation, enable usage of limited-use tokensvalai=Firebase.ai(backend=GenerativeBackend.googleAI(),useLimitedUseAppCheckTokens=true)// ...
Java
// ...// During instantiation, enable usage of limited-use tokensFirebaseAIai=FirebaseAI.getInstance(/* backend: */GenerativeBackend.googleAI(),/* useLimitedUseAppCheckTokens: */true);// ...
Web
// ...// During instantiation, enable usage of limited-use tokensconstai=getAI(firebaseApp,{backend:newGoogleAIBackend(),useLimitedUseAppCheckTokens:true});// ...
Dart
향후 출시에서는 Flutter 앱에서 제한된 사용 토큰을 사용하는 것이 지원됩니다. 나중에 다시 확인해 주세요.
Unity
Unity 게임에서 제한된 사용 토큰을 사용하는 기능은 향후 출시에서 지원될 예정입니다. 나중에 다시 확인해 주세요.
Firebase AI Logic이 App Check과 통합되는 방식 이해하기
Firebase AI Logic SDK를 사용하려면 Firebase 프로젝트에서 Firebase AI Logic API (firebasevertexai.googleapis.com)를 사용 설정해야 합니다. 이는 Firebase AI Logic SDK에서 전송된 요청이 먼저 Firebase AI Logic 서버로 전송되기 때문입니다. 이 서버는 요청이 선택한 'Gemini API' 제공업체의 백엔드와 Gemini 및 Imagen 모델에 액세스하는 API로 진행되기 전에 Firebase App Check 확인이 이루어지는 프록시 게이트웨이 역할을 합니다.
[null,null,["최종 업데이트: 2025-08-28(UTC)"],[],[],null,["\u003cbr /\u003e\n\nWhen you call an API directly from a mobile or web app (for example, the APIs\nthat allow access to generative AI models), the API is vulnerable to abuse by\nunauthorized clients. To help protect these APIs, you can use\n[Firebase App Check](/docs/app-check) to verify that all incoming API calls\nare from your actual app.\n\nFirebase AI Logic provides a proxy gateway that lets you integrate with\nFirebase App Check and protect the generative AI model APIs called by your\nmobile and web apps. Using App Check with the\nFirebase AI Logic SDKs supports all our configurations:\n\n- Protects both \"Gemini API\" providers: Gemini Developer API and\n Vertex AI Gemini API.\n\n- Protects all supported models, both Gemini models and Imagen\n models.\n\n| We **strongly recommend implementing\n| Firebase App Check into your app as early as possible**, even during development, so that every version of your app is protected from API abuse.\n\nHigh-level summary of how App Check works\n\nWith App Check, devices running your app use an app or device attestation\nprovider that verifies one or both of the following:\n\n- Requests originate from your authentic app\n- Requests originate from an authentic, untampered device\n\nThis attestation is attached to every request your app makes using a\nFirebase AI Logic SDK. When you enable App Check enforcement,\nrequests from clients without a valid attestation will be rejected, as will any\nrequest originating from an app or platform you haven't authorized.\n\nWe recommend that when you set up App Check, make sure to\n[prepare for upcoming enhanced protection](#enhanced-protection)\n(known as *replay protection*).\n\nYou can find [detailed information about App Check](/docs/app-check) in its\ndocumentation, including its [quotas and limits](/docs/app-check#quotas_limits).\n\nAvailable providers and implementation instructions\n\nThe App Check documentation provides descriptions of attestation providers\nas well as implementation instructions.\n\n1. Choose a default provider, and follow the implementation instructions at the\n following links:\n\n - **Apple platforms** : [DeviceCheck](/docs/app-check/ios/devicecheck-provider) or [App Attest](/docs/app-check/ios/app-attest-provider)\n - **Android** : [Play Integrity](/docs/app-check/android/play-integrity-provider)\n - **Web** : [reCAPTCHA Enterprise](/docs/app-check/web/recaptcha-enterprise-provider)\n - **Flutter** : Supports [all the default providers above](/docs/app-check/flutter/default-providers) \n Also, make sure to follow [special instantiation requirements](#instantiation-flutter) for Flutter and App Check.\n - **Unity** : Supports [all the default providers above](/docs/app-check/unity/default-providers)\n\n Note that if none of the default providers are sufficient for your needs,\n then you can [implement a custom provider](/docs/app-check/custom-provider)\n that uses either a third-party attestation provider or your own attestation\n techniques.\n2. *(Recommended)*\n [Prepare for upcoming enhanced protection from App Check](#enhanced-protection)\n (known as *replay protection*).\n\n3. *(Required)* Before you release your app to real users,\n [**enable enforcement of App Check**](/docs/app-check/enable-enforcement).\n\nSpecial instantiation required for Flutter\n\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| *Click your Gemini API provider to view provider-specific content and code on this page.* Gemini Developer API Vertex AI Gemini API |\n\nWhen using App Check with Firebase AI Logic in Flutter apps, you need to\nexplicitly pass in App Check during instantiation, like so: \n\n // ...\n\n final ai = await FirebaseAI.googleAI(\n appCheck: FirebaseAppCheck.instance, // for Flutter, pass in App Check explicitly\n );\n\n // ...\n\nPrepare for upcoming enhanced protection\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ***Using limited-use tokens is currently only available for Apple platforms (v12.2.0+), Android (v17.2.0+, BoM v34.2.0+), and Web (v12.3.0+) .** Support for other platforms will be released over the next several weeks.* |\n\nBy default, App Check uses *session tokens* which have a configurable\ntime to live (TTL) between 30 minutes and 7 days.\nThese session tokens are cached by the App Check SDK and sent along with\nrequests from your app.\n\nIn the future, App Check will add the option to enable *replay protection*\nfor Firebase AI Logic (similar to the support that App Check already\noffers for some other resources). When replay protection is enabled, it\nenhances protection in the following ways:\n\n- App Check will only allow requests if they're accompanied by a special\n kind of token called a *limited-use token*.\n\n- After the limited-use token is verified, the token is consumed so that it can\n be used only once, preventing replay attacks.\n\n**To prepare for replay protection, we recommend that you\n[enable the usage of limited-use tokens](#enable-limited-use-tokens)** as part\nof setting up App Check. That way, when replay protection becomes available,\nthen you can enable it sooner because more of your users will be on versions\nof your app that send limited-use tokens.\n\nNote the following if you enable usage of limited-use tokens in your app now\n(while replay protection is unavailable):\n\n- App Check does *not* block the usage of *valid session tokens*.\n\n- Just like session tokens, limited-use tokens are cached by the\n App Check SDK and sent along with requests. These limited-use tokens\n provide a *small* amount of additional protection than the default session\n tokens because limited-use tokens have a shorter TTL\n (only 5 minutes and not adjustable) compared to session tokens.\n\n- Even though limited-use tokens are valid for 5 minutes, the SDK\n will still generate a new token for *each* request. This process can add some\n latency to your request.\n\nHowever, when replay protection is available for Firebase AI Logic in the\nfuture (and you enable it), the use of session tokens and the reuse of\nlimited-use tokens won't be possible. Note that the additional latency for\ngenerating a new token for each request will still happen.\n\nEnable usage of limited-use tokens\n\n|-------------------------------------------------------------------------------------------------------------------------------------|\n| *Click your Gemini API provider to view provider-specific content and code on this page.* Gemini Developer API Vertex AI Gemini API |\n\n| **Note:** Consider setting up limited-use tokens to be a Firebase Remote Config parameter so that you can control its setting remotely rather than having it hard-coded in your app. Learn more about [using Remote Config](/docs/ai-logic/solutions/remote-config).\n\nHere's how to enable usage of limited-use tokens:\n\n1. [Implement App Check](#available-providers), and make sure that you've\n [enabled App Check enforcement](/docs/app-check/enable-enforcement)\n for your app.\n\n2. In your app during instantiation, enable the usage of limited-use tokens by\n setting the `useLimitedUseAppCheckTokens` parameter to `true`:\n\n Swift \n\n\n // ...\n\n // During instantiation, enable usage of limited-use tokens\n let ai = FirebaseAI.firebaseAI(\n backend: .googleAI(),\n useLimitedUseAppCheckTokens: true\n )\n\n // ...\n\n Kotlin \n\n\n // ...\n\n // During instantiation, enable usage of limited-use tokens\n val ai = Firebase.ai(\n backend = GenerativeBackend.googleAI(),\n useLimitedUseAppCheckTokens = true\n )\n\n // ...\n\n Java \n\n\n // ...\n\n // During instantiation, enable usage of limited-use tokens\n FirebaseAI ai = FirebaseAI.getInstance(\n /* backend: */ GenerativeBackend.googleAI(),\n /* useLimitedUseAppCheckTokens: */ true\n );\n\n // ...\n\n Web \n\n\n // ...\n\n // During instantiation, enable usage of limited-use tokens\n const ai = getAI(firebaseApp, {\n backend: new GoogleAIBackend(),\n useLimitedUseAppCheckTokens: true\n });\n\n // ...\n\n Dart\n\n Using limited-use tokens with Flutter apps will be supported in the\n upcoming release. Check back soon!\n\n Unity\n\n Using limited-use tokens with Unity games will be supported in a\n future release. Check back soon!\n\nUnderstand how Firebase AI Logic integrates with App Check\n\nTo use the Firebase AI Logic SDKs, the\n[Firebase AI Logic API (`firebasevertexai.googleapis.com`)](https://console.cloud.google.com/apis/library/firebasevertexai.googleapis.com?project=_)\nmust be enabled in your Firebase project. This is because requests made by the\nFirebase AI Logic SDKs are first sent to the Firebase AI Logic\nserver, which acts as a proxy gateway where Firebase App Check verification\ntakes place *before* the request is allowed to proceed to your chosen\n\"Gemini API\" provider's backend and the APIs to access the Gemini\nand Imagen models."]]