Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference
{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Class for Imagen model APIs.
This class provides methods for generating images using the Imagen model.
Signature:
export declare class ImagenModel extends VertexAIModel
Extends: VertexAIModel
Constructor | Modifiers | Description |
---|---|---|
(constructor)(vertexAI, modelParams, requestOptions) | (Public Preview) Constructs a new instance of the ImagenModel class. |
Property | Modifiers | Type | Description |
---|---|---|---|
generationConfig | ImagenGenerationConfig | (Public Preview) The Imagen generation configuration. | |
requestOptions | RequestOptions | undefined | (Public Preview) | |
safetySettings | ImagenSafetySettings | (Public Preview) Safety settings for filtering inappropriate content. |
Method | Modifiers | Description |
---|---|---|
generateImages(prompt) | (Public Preview) Generates images using the Imagen model and returns them as base64-encoded strings. |
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Constructs a new instance of the ImagenModel class.
Signature:
constructor(vertexAI: VertexAI, modelParams: ImagenModelParams, requestOptions?: RequestOptions | undefined);
Parameter | Type | Description |
---|---|---|
vertexAI | VertexAI | An instance of the Vertex AI in Firebase SDK. |
modelParams | ImagenModelParams | Parameters to use when making requests to Imagen. |
requestOptions | RequestOptions | undefined | Additional options to use when making requests. |
If the apiKey
or projectId
fields are missing in your Firebase config.
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
The Imagen generation configuration.
Signature:
generationConfig?: ImagenGenerationConfig;
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Signature:
requestOptions?: RequestOptions | undefined;
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Safety settings for filtering inappropriate content.
Signature:
safetySettings?: ImagenSafetySettings;
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Generates images using the Imagen model and returns them as base64-encoded strings.
If the prompt was not blocked, but one or more of the generated images were filtered, the returned object will have a filteredReason
property. If all images are filtered, the images
array will be empty.
Signature:
generateImages(prompt: string): Promise<ImagenGenerationResponse<ImagenInlineImage>>;
Parameter | Type | Description |
---|---|---|
prompt | string | A text prompt describing the image(s) to generate. |
Returns:
Promise<ImagenGenerationResponse<ImagenInlineImage>>
A promise that resolves to an ImagenGenerationResponse object containing the generated images.
If the request to generate images fails. This happens if the prompt is blocked.
const imagen = new ImagenModel(
vertexAI,
{
model: 'imagen-3.0-generate-002'
}
);
const response = await imagen.generateImages('A photo of a cat');
if (response.images.length > 0) {
console.log(response.images[0].bytesBase64Encoded);
}