Describe the bug
When enforcing Firebase App Check on a project utilizing Vertex AI for Firebase, the genui package fails to generate dynamic UI. This happens because the default factory (defaultGenerativeModelFactory) inside FirebaseAiContentGenerator hardcodes the FirebaseAI.googleAI() initialization. It does not expose any parameters to pass an appCheck instance or the useLimitedUseAppCheckTokens flag, resulting in an invalid App Check token error during generation.
To Reproduce
Steps to reproduce the behavior:
- Set up a Firebase project and enable the Vertex AI for Firebase API.
- Enable Firebase App Check in the Firebase console and enforce it specifically for the Firebase AI Logic service.
- In a Flutter project using the
genui package, initialize Firebase and activate App Check (e.g., FirebaseAppCheck.instance.activate(...)).
- Attempt to generate a dynamic UI component using
genui's default FirebaseAiContentGenerator without a custom modelCreator.
- Trigger the UI generation.
- See error: The generation fails, and the console outputs a permission denied or invalid App Check token error because the default factory did not attach the App Check token to the request.
Expected behavior
The FirebaseAiContentGenerator and its default factory should allow developers to pass optional FirebaseAppCheck configurations down to the underlying FirebaseAI.googleAI() initialization. The dynamic UI should generate successfully without authentication errors, rather than requiring developers to completely rewrite the default model factory just to inject the App Check parameter.
Additional context
Currently, the only way to bypass this is to manually install the firebase_ai package and completely override the modelCreator like this:
_generator = FirebaseAiContentGenerator(
catalog: insightCatalogRegistry,
modelCreator: ({required configuration, systemInstruction, toolConfig, tools}) => GeminiGenerativeModel(
FirebaseAI.googleAI(
appCheck: FirebaseAppCheck.instance, // Manually passed here
useLimitedUseAppCheckTokens: true,
).generativeModel(
model: 'gemini-2.5-flash',
systemInstruction: systemInstruction,
tools: tools,
toolConfig: toolConfig,
),
),
);
Exposing appCheck and useLimitedUseAppCheckTokens as optional parameters in FirebaseAiContentGenerator would resolve this friction. I would be happy to open a PR for this if the team agrees with this approach!
Describe the bug
When enforcing Firebase App Check on a project utilizing Vertex AI for Firebase, the
genuipackage fails to generate dynamic UI. This happens because the default factory (defaultGenerativeModelFactory) insideFirebaseAiContentGeneratorhardcodes theFirebaseAI.googleAI()initialization. It does not expose any parameters to pass anappCheckinstance or theuseLimitedUseAppCheckTokensflag, resulting in an invalid App Check token error during generation.To Reproduce
Steps to reproduce the behavior:
genuipackage, initialize Firebase and activate App Check (e.g.,FirebaseAppCheck.instance.activate(...)).genui's defaultFirebaseAiContentGeneratorwithout a custommodelCreator.Expected behavior
The
FirebaseAiContentGeneratorand its default factory should allow developers to pass optionalFirebaseAppCheckconfigurations down to the underlyingFirebaseAI.googleAI()initialization. The dynamic UI should generate successfully without authentication errors, rather than requiring developers to completely rewrite the default model factory just to inject the App Check parameter.Additional context
Currently, the only way to bypass this is to manually install the
firebase_aipackage and completely override themodelCreatorlike this:Exposing
appCheckanduseLimitedUseAppCheckTokensas optional parameters inFirebaseAiContentGeneratorwould resolve this friction. I would be happy to open a PR for this if the team agrees with this approach!