firebase-admin.machine-learning package

Firebase ML is deprecated and will be shut down on June 15, 2027. To host custom models, you must migrate to another solution. You can use Cloud Storage for Firebase as an alternative for hosting custom models. For more info, see https://firebase.google.com/docs/ml/migrate-to-cloud-storage

Firebase Machine Learning.

Functions

Function Description
getMachineLearning(app) Gets the MachineLearning service for the default app or a given app.getMachineLearning() can be called with no arguments to access the default app's MachineLearning service or as getMachineLearning(app) to access the MachineLearning service associated with a specific app.

Classes

Class Description
FirebaseMachineLearningError Firebase Machine Learning error code structure. This extends FirebaseError.
MachineLearning The Firebase MachineLearning service interface.
Model A Firebase ML Model output object.

Interfaces

Interface Description
GcsTfliteModelOptions
ListModelsOptions Interface representing options for listing Models.
ListModelsResult Response object for a listModels operation.
ModelOptionsBase Firebase ML Model input objects
TFLiteModel A TensorFlow Lite Model output object

Variables

Variable Description
MachineLearningErrorCode The constant mapping for valid Machine Learning client error codes.

Type Aliases

Type Alias Description
MachineLearningErrorCode The type definition for valid Machine Learning client error codes.
ModelOptions

getMachineLearning(app)

Firebase ML is deprecated and will be shut down on June 15, 2027. To host custom models, you must migrate to another solution. You can use Cloud Storage for Firebase as an alternative for hosting custom models. For more info, see https://firebase.google.com/docs/ml/migrate-to-cloud-storage

Gets the MachineLearning service for the default app or a given app.

getMachineLearning() can be called with no arguments to access the default app's MachineLearning service or as getMachineLearning(app) to access the MachineLearning service associated with a specific app.

Signature:

export declare function getMachineLearning(app?: App): MachineLearning;

Parameters

Parameter Type Description
app App Optional app whose MachineLearning service to return. If not provided, the default MachineLearning service will be returned.

Returns:

MachineLearning

The default MachineLearning service if no app is provided or the MachineLearning service associated with the provided app.

Example 1

// Get the MachineLearning service for the default app
const defaultMachineLearning = getMachineLearning();

Example 2

// Get the MachineLearning service for a given app
const otherMachineLearning = getMachineLearning(otherApp);

MachineLearningErrorCode

Firebase ML is deprecated and will be shut down on June 15, 2027. To host custom models, you must migrate to another solution. You can use Cloud Storage for Firebase as an alternative for hosting custom models. For more info, see https://firebase.google.com/docs/ml/migrate-to-cloud-storage

The constant mapping for valid Machine Learning client error codes.

Signature:

MachineLearningErrorCode: {
    readonly ALREADY_EXISTS: "already-exists";
    readonly AUTHENTICATION_ERROR: "authentication-error";
    readonly INTERNAL_ERROR: "internal-error";
    readonly INVALID_ARGUMENT: "invalid-argument";
    readonly INVALID_SERVER_RESPONSE: "invalid-server-response";
    readonly NOT_FOUND: "not-found";
    readonly RESOURCE_EXHAUSTED: "resource-exhausted";
    readonly SERVICE_UNAVAILABLE: "service-unavailable";
    readonly UNKNOWN_ERROR: "unknown-error";
    readonly CANCELLED: "cancelled";
    readonly DEADLINE_EXCEEDED: "deadline-exceeded";
    readonly PERMISSION_DENIED: "permission-denied";
    readonly FAILED_PRECONDITION: "failed-precondition";
    readonly ABORTED: "aborted";
    readonly OUT_OF_RANGE: "out-of-range";
    readonly DATA_LOSS: "data-loss";
    readonly UNAUTHENTICATED: "unauthenticated";
}

MachineLearningErrorCode

Firebase ML is deprecated and will be shut down on June 15, 2027. To host custom models, you must migrate to another solution. You can use Cloud Storage for Firebase as an alternative for hosting custom models. For more info, see https://firebase.google.com/docs/ml/migrate-to-cloud-storage

The type definition for valid Machine Learning client error codes.

Signature:

export type MachineLearningErrorCode = typeof MachineLearningErrorCode[keyof typeof MachineLearningErrorCode];

ModelOptions

Firebase ML is deprecated and will be shut down on June 15, 2027. To host custom models, you must migrate to another solution. You can use Cloud Storage for Firebase as an alternative for hosting custom models. For more info, see https://firebase.google.com/docs/ml/migrate-to-cloud-storage

Signature:

export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions;