Firebase AI Quickstart
June 25, 2026 ยท View on GitHub
This sample demonstrates how to make calls to the Gemini API via Firebase directly from your app, rather than server-side, using the Vertex AI for Firebase SDK.
Getting Started
Clone and open the sample project
- Clone this repo.
- Change into the
firebaseaidirectory. - Open
FirebaseAIExample.xcodeprojusing Xcode.git clone https://github.com/firebase/quickstart-ios.git cd quickstart-ios/firebaseai open FirebaseAIExample.xcodeproj - Select the
FirebaseAIExample (iOS)scheme in Xcode to build the app using the Swift Package Manager distribution.
Connect the sample to your Firebase project
To have a functional application, you will need to connect the Firebase AI sample app to your Firebase project (or create a new project):
- Follow the instructions in Set up a Firebase project and connect your app to Firebase.
- Add an iOS+ app to your project. Make sure the
Bundle Identifieryou set matches the one in the sample.- The default bundle ID is
com.google.firebase.quickstart.FirebaseAIExample
- The default bundle ID is
- Download the
GoogleService-Info.plistfor the app when prompted and save it to thefirebaseaidirectory.
You should now be able to build and run the sample!
Request logging
The -FIRDebugEnabled option is set as a command line argument in the build
scheme to log server requests to the console. Remove the option to turn off the
logging.
Firebase App Check
Firebase App Check protects your Vertex AI / Gemini API resources from abuse.
To simplify getting started, and to support Simulators, this sample app is
configured to use the Firebase App Check debug provider
AppCheckDebugProviderFactory. If you've configured a different provider in the
Firebase Console, update AppCheck.setAppCheckProviderFactory(...) in the
sample code to match your configured App Check provider.
To make successful API requests when running the app:
- Locate the generated local debug token in your Xcode console output (look
for a line like:
<Warning> [AppCheckCore][I-GAC004001] App Check debug token: '<YOUR_TOKEN>'). - Copy this token.
- Register the token in the
Firebase Console under App Check
Apps Manage debug tokens from your app's overflow menu (vertical dots).
For more details, see the official guide: Use the App Check debug provider on Apple platforms.
Usability Tip: Fixed Debug Token for Simulators
To avoid registering a new random debug token every time you restart/reset a simulator, you can configure a fixed debug token in Xcode:
- In the Firebase Console, generate a custom debug token.
- In Xcode, edit your active build scheme (Product > Scheme > Edit Scheme...).
- Under the Run section, select the Arguments tab.
- In the Environment Variables section, add a variable with the name
AppCheckDebugTokenand the value<YOUR_CUSTOM_TOKEN>.
Caution
Keep your debug token secret. Anyone who has access to a valid debug token can access your project's backend resources as a legitimate client. Never check debug tokens, or schemes containing them, into version control (like Git).
WARNING: Production Deployment
The App Check debug provider is only intended for development/testing environments. Before distributing your app to the App Store, you must migrate to a production-grade provider (such as AppAttest or DeviceCheck). Refer to the following guides:
Documentation
To learn more about the Firebase AI SDK, check out the documentation.
Support
- GitHub Issue
- File an issue in the
firebase-ios-sdkrepo, choosing the Firebase AI product.
- File an issue in the
- Firebase Support