Skip to content

Commit a7e74c4

Browse files
fix(ai): drop the getImagenModel wrapper, removed in firebase 12.18
Firebase shut the Imagen models down in August 2026 and @firebase/ai 2.15.0 (firebase 12.18.0) removed the API. Our ai entry point named-imports getImagenModel, so any install resolving firebase 12.18.0, which ^12.4.0 does on every fresh install, fails to build. The generator now excludes getImagenModel from the wrapped named imports. Installs whose firebase still includes the symbol (12.17 and older) keep compiling, because the entry point re-exports everything from firebase/ai with export *. That is compile-time grace only: the models are shut down, so the calls fail at the service on any firebase version. The package keeps building against firebase 12.4.0, the lowest version the published ^12.4.0 range allows, so every symbol the generated file imports by name exists in every firebase version a user's install can resolve: a sweep of every wrapped @firebase package between the 12.4.0- and 12.18.0-mapped versions found getImagenModel to be the only removed export. The ng update migration now warns on getImagenModel imports with guidance to move image generation to the Gemini image models via getGenerativeModel, with a spec. The upgrade guide documents the removal and its migration section is restructured for readability.
1 parent fb6796b commit a7e74c4

6 files changed

Lines changed: 46 additions & 5 deletions

File tree

docs/ai.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# AI Logic
66

7-
Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models and Imagen models.
7+
Firebase AI Logic gives you access to the latest generative AI models from Google: the Gemini models, including the Gemini image models.
88

99
[Learn more](https://firebase.google.com/docs/ai-logic)
1010

docs/version-21-upgrade.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,28 @@ The Vertex AI module has been renamed to Firebase AI Logic. The `@angular/fire/v
3232

3333
**`getVertexAI` is not a plain rename.** `getAI` already existed alongside it, and a plain `getAI()` call talks to the Gemini Developer API backend, not to Vertex AI. The equivalent of `getVertexAI()` is `getAI(app, { backend: new VertexAIBackend() })`, which is what the migration writes, so your app keeps calling the Vertex AI backend it was configured, enabled, and billed for. A `location` option moves into the `VertexAIBackend` constructor.
3434

35-
`ng update @angular/fire` rewrites these imports and identifiers for you and logs every `getVertexAI` call it rewrites. Code it cannot rewrite safely (for example when the options are not a literal `{ location }` object or that literal references other rewritten symbols, when the function itself is handed around as a value, when a local declaration in the file reuses an imported symbol's name, or when the file already binds `getAI` or `VertexAIBackend` from a source other than AI Logic) is left in place with a warning. The import path itself still moves to the new entry point, so the leftover code fails to compile there, and nothing changes backends silently. A file where a named `getVertexAI` import has any use that cannot be rewritten keeps every use of its named `getVertexAI` imports in place (namespace-style `ns.getVertexAI(...)` calls are judged per call), and each skipped call is logged. `export * from '@angular/fire/vertexai'` is also left alone (rewriting it would silently rename your re-exported public symbols), so replace it with named re-exports by hand. `VertexAIOptions` was removed rather than renamed (the new `AIOptions` takes a `backend` instead of a `location`), so imports of it are left and warned about. Migrate those sites using the table above. `getGenerativeModel` and `getImagenModel` keep their names.
35+
`ng update @angular/fire` rewrites these imports and identifiers for you and logs every `getVertexAI` call it rewrites. `getGenerativeModel` keeps its name.
3636

3737
Imports straight from the Firebase SDK (`firebase/vertexai`, gone in SDK 12) are rewritten to `firebase/ai` under the same rules. The rewrite parses your sources with the `typescript` package (an optional peer dependency of `@angular/fire`). Every Angular workspace already has it, but if the migration warns that it could not be resolved, install `typescript` and re-run. See [ai.md](./ai.md) for current usage.
3838

39+
### What the migration will not rewrite
40+
41+
Code the migration cannot rewrite safely is left in place with a warning. The import path itself still moves to the new entry point, so the leftover code fails to compile there. Nothing changes backends silently. It plays safe like this in four situations:
42+
43+
- **Options it cannot read:** when the `getVertexAI` call's options are not a literal `{ location }` object, or that literal references other symbols the migration is also rewriting.
44+
- **The function used as a value:** when `getVertexAI` is stored or passed around rather than called directly.
45+
- **Name collisions:** when a local declaration in the file reuses an imported symbol's name, or the file already gets `getAI` or `VertexAIBackend` from a source other than AI Logic.
46+
- **Wildcard re-exports:** when a file has `export * from '@angular/fire/vertexai'`, that line stays as written, because rewriting it would silently rename your re-exported public symbols. Replace it with named re-exports by hand.
47+
48+
A file where a named `getVertexAI` import is used in a way that cannot be rewritten keeps every use of its named `getVertexAI` imports in place (namespace-style `ns.getVertexAI(...)` calls are judged per call), and each skipped call is logged.
49+
50+
### Removed symbols
51+
52+
Two symbols were removed rather than renamed. The migration leaves their imports in place, which breaks loudly, and warns with guidance:
53+
54+
- `VertexAIOptions`: the new `AIOptions` takes a `backend` instead of a `location`, so rebuild the options by hand using the table above.
55+
- `getImagenModel`: Firebase shut the Imagen models down in August 2026 and removed the API in firebase 12.18 (`@firebase/ai` 2.15), so move image generation to the Gemini image models through [`getGenerativeModel`](https://firebase.google.com/docs/ai-logic/generate-images-gemini).
56+
3957
## Other notes
4058

4159
- **Angular 21 is required.** AngularFire 21 peers `@angular/* ^21.0.0` and does not support Angular 22 (a future AngularFire 22 will).

src/ai/firebase.ts

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/schematics/update/v21/vertexai-to-ai.jasmine.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,24 @@ describe('rewriteVertexAIToAI', () => {
746746
expect(warn.calls.mostRecent().args[0]).toContain('no longer exists in the new entry point');
747747
});
748748

749+
it('leaves getImagenModel in place and warns that the Imagen API is gone', () => {
750+
const { context: spiedContext, warn } = contextWithLogSpies();
751+
const source = [
752+
`import { getVertexAI, getImagenModel } from '@angular/fire/vertexai';`,
753+
`export const a = getVertexAI();`,
754+
`export const model = getImagenModel(a, { model: 'imagen-3.0-generate-002' });`,
755+
].join('\n');
756+
const tree = treeWith({ 'src/app/foo.ts': source });
757+
758+
rewriteVertexAIToAI(tree, spiedContext, typescript);
759+
760+
const out = tree.readText('src/app/foo.ts');
761+
expect(out).toContain(`import { getAI, VertexAIBackend, getImagenModel } from '@angular/fire/ai';`);
762+
expect(out).toContain(`getImagenModel(a, { model: 'imagen-3.0-generate-002' });`);
763+
expect(warn).toHaveBeenCalledTimes(1);
764+
expect(warn.calls.mostRecent().args[0]).toContain('Imagen models were shut down');
765+
});
766+
749767
it('reuses an existing VertexAIBackend import instead of adding a second one', () => {
750768
const source = [
751769
`import { VertexAIBackend } from '@angular/fire/ai';`,

src/schematics/update/v21/vertexai-to-ai/tables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const SYMBOL_RENAMES: Record<string, string> = {
3030
// replacement, so the import keeps its name (breaking loudly) and the log explains why.
3131
export const REMOVED_SYMBOL_GUIDANCE: Record<string, string> = {
3232
VertexAIOptions: 'the new AIOptions takes a backend instead of a location, rebuild the options by hand',
33+
getImagenModel: 'the Imagen models were shut down in August 2026 and firebase 12.18 removed the API, move image generation to the Gemini image models through getGenerativeModel',
3334
};
3435

3536
export const GET_VERTEX_AI = 'getVertexAI';

tools/build.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ ${exportedZoneWrappedFns}
114114
await writeFile(filePath, fileOutput);
115115
};
116116
return Promise.all([
117-
reexport('ai', 'firebase', 'firebase/ai', tsKeys<typeof import('firebase/ai')>()),
117+
reexport('ai', 'firebase', 'firebase/ai', tsKeys<typeof import('firebase/ai')>(), {
118+
// Removed in @firebase/ai 2.15.0 (firebase 12.18.0), which the ^12.4.0 range
119+
// resolves for fresh installs. A named import here would make consumer builds
120+
// fail on that version, so only re-export it through the star export, which
121+
// tracks whichever firebase is installed.
122+
getImagenModel: null,
123+
}),
118124
reexport('analytics', 'firebase', 'firebase/analytics', tsKeys<typeof import('firebase/analytics')>(), {
119125
isSupported: { blockUntilFirst: false },
120126
logEvent: { blockUntilFirst: false, logLevel: LogLevel.VERBOSE },

0 commit comments

Comments
 (0)