ChromeAdapter interface
Stay organized with collections
Save and categorize content based on your preferences.
(EXPERIMENTAL) Defines an inference "backend" that uses Chrome's on-device model, and encapsulates logic for detecting when on-device inference is possible.
These methods should not be called directly by the user.
Signature:
export interface ChromeAdapter
Methods
ChromeAdapter.generateContent()
Generates content using on-device inference.
This is comparable to GenerativeModel.generateContent() for generating content using in-cloud inference.
Signature:
generateContent(request: GenerateContentRequest): Promise<Response>;
Parameters
Returns:
Promise<Response>
ChromeAdapter.generateContentStream()
Generates a content stream using on-device inference.
This is comparable to GenerativeModel.generateContentStream() for generating a content stream using in-cloud inference.
Signature:
generateContentStream(request: GenerateContentRequest): Promise<Response>;
Parameters
Returns:
Promise<Response>
ChromeAdapter.isAvailable()
Checks if the on-device model is capable of handling a given request.
Signature:
isAvailable(request: GenerateContentRequest): Promise<boolean>;
Parameters
Returns:
Promise<boolean>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[null,null,["Last updated 2025-08-07 UTC."],[],[],null,["# ChromeAdapter interface\n\n**(EXPERIMENTAL)** Defines an inference \"backend\" that uses Chrome's on-device model, and encapsulates logic for detecting when on-device inference is possible.\n\nThese methods should not be called directly by the user.\n\n**Signature:** \n\n export interface ChromeAdapter \n\nMethods\n-------\n\n| Method | Description |\n|--------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|\n| [generateContent(request)](./ai.chromeadapter.md#chromeadaptergeneratecontent) | Generates content using on-device inference. |\n| [generateContentStream(request)](./ai.chromeadapter.md#chromeadaptergeneratecontentstream) | Generates a content stream using on-device inference. |\n| [isAvailable(request)](./ai.chromeadapter.md#chromeadapterisavailable) | Checks if the on-device model is capable of handling a given request. |\n\nChromeAdapter.generateContent()\n-------------------------------\n\nGenerates content using on-device inference.\n\nThis is comparable to [GenerativeModel.generateContent()](./ai.generativemodel.md#generativemodelgeneratecontent) for generating content using in-cloud inference.\n\n**Signature:** \n\n generateContent(request: GenerateContentRequest): Promise\u003cResponse\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|\n| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | a standard Firebase AI [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) |\n\n**Returns:**\n\nPromise\\\u003cResponse\\\u003e\n\nChromeAdapter.generateContentStream()\n-------------------------------------\n\nGenerates a content stream using on-device inference.\n\nThis is comparable to [GenerativeModel.generateContentStream()](./ai.generativemodel.md#generativemodelgeneratecontentstream) for generating a content stream using in-cloud inference.\n\n**Signature:** \n\n generateContentStream(request: GenerateContentRequest): Promise\u003cResponse\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|-------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|\n| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | a standard Firebase AI [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) |\n\n**Returns:**\n\nPromise\\\u003cResponse\\\u003e\n\nChromeAdapter.isAvailable()\n---------------------------\n\nChecks if the on-device model is capable of handling a given request.\n\n**Signature:** \n\n isAvailable(request: GenerateContentRequest): Promise\u003cboolean\u003e;\n\n#### Parameters\n\n| Parameter | Type | Description |\n|-----------|-------------------------------------------------------------------------------------------|------------------------------------------------|\n| request | [GenerateContentRequest](./ai.generatecontentrequest.md#generatecontentrequest_interface) | A potential request to be passed to the model. |\n\n**Returns:**\n\nPromise\\\u003cboolean\\\u003e"]]