React Native Firebase
    Preparing search index...

    Class for Imagen model APIs.

    This class provides methods for generating images using the Imagen model.

    const imagen = new ImagenModel(
    ai,
    {
    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);
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Beta

      Generates images using the Imagen model and returns them as base64-encoded strings.

      Parameters

      • 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.

      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.

    • Internal

      Generates images to Cloud Storage for Firebase using the Imagen model.

      This method is temporarily internal.

      Parameters

      • prompt: string

        A text prompt describing the image(s) to generate.

      • gcsURI: string

        The URI of file stored in a Cloud Storage for Firebase bucket. This should be a directory. For example, gs://my-bucket/my-directory/.

      Returns Promise<ImagenGenerationResponse<ImagenGCSImage>>

      A promise that resolves to an ImagenGenerationResponse object containing the URLs of the generated images.

      If the request fails to generate images fails. This happens if the prompt is blocked.

      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.

    • Internal

      Normalizes the given model name to a fully qualified model resource name.

      Parameters

      • modelName: string

        The model name to normalize.

      • backendType: BackendType

      Returns string

      The fully qualified model resource name.

    Properties

    _apiSettings: ApiSettings
    generationConfig?: ImagenGenerationConfig

    The Imagen generation configuration.

    model: string

    The fully qualified model resource name to use for generating images (for example, publishers/google/models/imagen-3.0-generate-002).

    requestOptions?: RequestOptions

    Additional options to use when making requests.

    safetySettings?: ImagenSafetySettings

    Safety settings for filtering inappropriate content.