docs-devsite/ai.generativemodel.md
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 %}
Class for generative model APIs.
<b>Signature:</b>
export declare class GenerativeModel extends AIModel
<b>Extends:</b> AIModel
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(ai, modelParams, requestOptions, chromeAdapter) | Constructs a new instance of the <code>GenerativeModel</code> class |
| Property | Modifiers | Type | Description |
|---|---|---|---|
| generationConfig | GenerationConfig | ||
| requestOptions | RequestOptions | ||
| safetySettings | SafetySetting<!-- -->[] | ||
| systemInstruction | Content | ||
| toolConfig | ToolConfig | ||
| tools | Tool<!-- -->[] |
| Method | Modifiers | Description |
|---|---|---|
| countTokens(request, singleRequestOptions) | Counts the tokens in the provided request. | |
| generateContent(request, singleRequestOptions) | Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse<!-- -->. | |
| generateContentStream(request, singleRequestOptions) | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | |
| startChat(startChatParams) | Gets a new ChatSession instance which can be used for multi-turn chats. |
Constructs a new instance of the GenerativeModel class
<b>Signature:</b>
constructor(ai: AI, modelParams: ModelParams, requestOptions?: RequestOptions, chromeAdapter?: ChromeAdapter | undefined);
| Parameter | Type | Description |
|---|---|---|
| ai | AI | |
| modelParams | ModelParams | |
| requestOptions | RequestOptions | |
| chromeAdapter | ChromeAdapter | undefined |
<b>Signature:</b>
generationConfig: GenerationConfig;
<b>Signature:</b>
requestOptions?: RequestOptions;
<b>Signature:</b>
safetySettings: SafetySetting[];
<b>Signature:</b>
systemInstruction?: Content;
<b>Signature:</b>
toolConfig?: ToolConfig;
<b>Signature:</b>
tools?: Tool[];
Counts the tokens in the provided request.
<b>Signature:</b>
countTokens(request: CountTokensRequest | string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<CountTokensResponse>;
| Parameter | Type | Description |
|---|---|---|
| request | CountTokensRequest | string | Array<string | Part<!-- -->> | |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<CountTokensResponse<!-- -->>
Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse<!-- -->.
<b>Signature:</b>
generateContent(request: GenerateContentRequest | string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | string | Array<string | Part<!-- -->> | |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentResult<!-- -->>
Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response.
<b>Signature:</b>
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>, singleRequestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | string | Array<string | Part<!-- -->> | |
| singleRequestOptions | SingleRequestOptions |
<b>Returns:</b>
Promise<GenerateContentStreamResult<!-- -->>
Gets a new ChatSession instance which can be used for multi-turn chats.
<b>Signature:</b>
startChat(startChatParams?: StartChatParams): ChatSession;
| Parameter | Type | Description |
|---|---|---|
| startChatParams | StartChatParams |
<b>Returns:</b>