Technical Documentation: google-gemini/generative-ai-js
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (`README.md`)
[Deprecated] Google AI JavaScript SDK for the Gemini API
With Gemini 2.0, we took the chance to create a single unified SDK for all developers who want to use Google's GenAI models (Gemini, Veo, Imagen, etc). As part of that process, we took all of the feedback from this SDK and what developers like about other SDKs in the ecosystem to create the Google Gen AI SDK.
The full migration guide from the old SDK to new SDK is available in the Gemini API docs.
The Gemini API docs are fully updated to show examples of the new Google Gen AI SDK. We know how disruptive an SDK change can be and don't take this change lightly, but our goal is to create an extremely simple and clear path for developers to build with our models so it felt necessary to make this change.
Thank you for building with Gemini and let us know if you need any help!
Please be advised that this repository is now considered legacy. For the latest features, performance improvements, and active development, we strongly recommend migrating to the official Google Generative AI SDK for JavaScript.
Support Plan for this Repository:
- Limited Maintenance: Development is now restricted to critical bug fixes only. No new features will be added.
- Purpose: This limited support aims to provide stability for users while they transition to the new SDK.
- End-of-Life Date: All support for this repository (including bug fixes) will permanently end on November 30, 2025.
We encourage all users to begin planning their migration to the Google Generative AI SDK to ensure continued access to the latest capabilities and support.
Overview (`samples/README.md`)
Google Generative AI Samples for JavaScript
These samples demonstrate how to use state-of-the-art
generative AI models (like Gemini) to build AI-powered features and applications.
To try out these samples, you'll need Node.js v18+.
For some samples of how to adapt this to web, see the web/ subdirectory.
Requirements
Follow the instructions on Google AI Studio setup page to obtain an API key.
It’s strongly recommended that you do not check an API key into your version control system. Instead, you should use a secrets store for your API key.
This sample assumes that you're providing an API_KEY environment variable.
Instructions
Each of these sample files can be run in Node.js from the command line, for
example:
node function_calling.jsSome of these files run multiple example cases sequentially, and you may want
to comment out cases you do not want to run.
Documentation
Contents
| File | Description |
|---|---|
| cache.js | Context caching |
| chat.js | Multi-turn chat conversations |
| code_execution.js | Executing code |
| model_configuration.js | Setting model parameters |
| controlled_generation.js | Generating content with output constraints (e.g. JSON mode) |
| count_tokens.js | Counting input and output tokens |
| embed.js | Generating embeddings |
| files.js | Managing files with the File API |
| function_calling.js | Using function calling |
| safety_settings.js | Setting and using safety controls |
| system_instruction.js | Setting system instructions |
| search_grounding.js | Generate with google search grounding |
| log_prob.js | Generate with log probability for each token |
| text_generation.js | Generating text |
| api_version.js | Setting api version |
Overview (`samples/web/README.md`)
Google Generative AI Sample for Web (Javascript)
This sample app demonstrates how to use state-of-the-art
generative AI models (like Gemini) to build AI-powered features and applications.
To try out this sample app, you'll need a modern web browser and a local http server.
Requirements
Follow the instructions on Google AI Studio setup page to obtain an API key.
It’s strongly recommended that you do not check an API key into your version control system. Instead, you should use a secrets store for your API key.
The Node.js http server provided alonside this app (http-server.js) assumes that you're providing an API_KEY environment variable.
Features
This sample showcases the following API capablilites:
index.html- demonstrates the Text and MultiModal feature from the SDKchat.html- demonstrates the Multi-turn Conversations feature from the SDK
Documentation
Reference Files Index (`docs/reference/files/index.md`)
API Reference
Packages
| Package | Description |
|---|---|
| @google/generative-ai |
Reference Main Generative Ai.Citationsource.Endindex (`docs/reference/main/generative-ai.citationsource.endindex.md`)
Home > @google/generative-ai > CitationSource > endIndex
CitationSource.endIndex property
Signature:
endIndex?: number;Reference Main Generative Ai.Citationsource.Startindex (`docs/reference/main/generative-ai.citationsource.startindex.md`)
Home > @google/generative-ai > CitationSource > startIndex
CitationSource.startIndex property
Signature:
startIndex?: number;Reference Main Generative Ai.Generatecontentcandidate.Index (`docs/reference/main/generative-ai.generatecontentcandidate.index.md`)
Home > @google/generative-ai > GenerateContentCandidate > index
GenerateContentCandidate.index property
Signature:
index: number;Reference Main Generative Ai.Groundingsupportsegment.Endindex (`docs/reference/main/generative-ai.groundingsupportsegment.endindex.md`)
Home > @google/generative-ai > GroundingSupportSegment > endIndex
GroundingSupportSegment.endIndex property
End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero.
Signature:
endIndex?: number;Reference Main Generative Ai.Groundingsupportsegment.Partindex (`docs/reference/main/generative-ai.groundingsupportsegment.partindex.md`)
Home > @google/generative-ai > GroundingSupportSegment > partIndex
GroundingSupportSegment.partIndex property
The index of a Part object within its parent Content object.
Signature:
partIndex?: number;Reference Main Generative Ai.Groundingsupportsegment.Startindex (`docs/reference/main/generative-ai.groundingsupportsegment.startindex.md`)
Home > @google/generative-ai > GroundingSupportSegment > startIndex
GroundingSupportSegment.startIndex property
Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero.
Signature:
startIndex?: number;Reference Main Index (`docs/reference/main/index.md`)
API Reference
Packages
| Package | Description |
|---|---|
| @google/generative-ai |
Reference Server Index (`docs/reference/server/index.md`)
API Reference
Packages
| Package | Description |
|---|---|
| @google/generative-ai |
Code Of Conduct (`docs/code-of-conduct.md`)
Code of Conduct
Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
Our Standards
Examples of behavior that contributes to creating a positive environment
include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or
advances - Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission - Other conduct which could reasonably be considered inappropriate in a
professional setting
Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening,
offensive, or harmful.
Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
This Code of Conduct also applies outside the project spaces when the Project
Steward has a reasonable belief that an individual's behavior may have a
negative impact on the project or its community.
Conflict Resolution
We do not believe that all conflict is bad; healthy debate and disagreement
often yield positive results. However, it is never okay to be disrespectful or
to engage in behavior that violates the project’s code of conduct.
If you see someone violating the code of conduct, you are encouraged to address
the behavior directly with those involved. Many issues can be resolved quickly
and easily, and this gives people more control over the outcome of their
dispute. If you are unable to resolve the matter for any reason, or if the
behavior is threatening or harassing, report it. We are dedicated to providing
an environment where participants feel welcome and safe.
Reports should be directed to [PROJECT STEWARD NAME(s) AND EMAIL(s)], the
Project Steward(s) for [PROJECT NAME]. It is the Project Steward’s duty to
receive and address reported violations of the code of conduct. They will then
work with a committee consisting of representatives from the Open Source
Programs Office and the Google Open Source Strategy team. If for any reason you
are uncomfortable reaching out to the Project Steward, please email
[email protected].
We will investigate every complaint, but you may not receive a direct response.
We will use our discretion in determining when and how to follow up on reported
incidents, which may range from not taking action to permanent expulsion from
the project and project-sponsored spaces. We will notify the accused of the
report and provide them an opportunity to discuss it before any action is taken.
The identity of the reporter will be omitted from the details of the report
supplied to the accused. In potentially harmful situations, such as ongoing
harassment or threats to anyone's safety, we may take action without notice.
Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct/
Contributing (`docs/contributing.md`)
How to Contribute
We would love to accept your patches and contributions to this project.
Before you begin
Sign our Contributor License Agreement
Contributions to this project must be accompanied by a
Contributor License Agreement (CLA).
You (or your employer) retain the copyright to your contribution; this simply
gives us permission to use and redistribute your contributions as part of the
project.
If you or your current employer have already signed the Google CLA (even if it
was for a different project), you probably don't need to do it again.
Visit https://cla.developers.google.com/ to see your current agreements or to
sign a new one.
Review our Community Guidelines
This project follows Google's Open Source Community
Guidelines.
Contribution process
Building and testing locally
Steps to build locally:
- clone this repo
cd generative-ai-js- Run
npm installto install dependencies. - Make changes as needed to source code.
- Run
npm run buildto build. - Run
npm run testto run unit tests. - Run
npm run docsto generate any changes to reference docs (destination dir is docs/reference). - Run
npm run formatto fix formatting and add license headers as needed. - Run
npx @changesets/clito generate the changeset summary.
Code Reviews
All submissions, including submissions by project members, require review. We
use GitHub pull requests
for this purpose.
Reference Files Generative Ai.Errordetails. Type (`docs/reference/files/generative-ai.errordetails.__type_.md`)
Home > @google/generative-ai > ErrorDetails > "@type"
ErrorDetails."@type" property
Signature:
"@type"?: string;Reference Files Generative Ai.Errordetails.Domain (`docs/reference/files/generative-ai.errordetails.domain.md`)
Home > @google/generative-ai > ErrorDetails > domain
ErrorDetails.domain property
Signature:
domain?: string;Reference Files Generative Ai.Errordetails (`docs/reference/files/generative-ai.errordetails.md`)
Home > @google/generative-ai > ErrorDetails
ErrorDetails interface
Details object that may be included in an error response.
Signature:
export interface ErrorDetailsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| "@type"? | string | (Optional) | |
| domain? | string | (Optional) | |
| metadata? | Record<string, unknown> | (Optional) | |
| reason? | string | (Optional) |
Reference Files Generative Ai.Errordetails.Metadata (`docs/reference/files/generative-ai.errordetails.metadata.md`)
Home > @google/generative-ai > ErrorDetails > metadata
ErrorDetails.metadata property
Signature:
metadata?: Record<string, unknown>;Reference Files Generative Ai.Errordetails.Reason (`docs/reference/files/generative-ai.errordetails.reason.md`)
Home > @google/generative-ai > ErrorDetails > reason
ErrorDetails.reason property
Signature:
reason?: string;Reference Files Generative Ai.Filemetadata.Displayname (`docs/reference/files/generative-ai.filemetadata.displayname.md`)
Home > @google/generative-ai > FileMetadata > displayName
FileMetadata.displayName property
Signature:
displayName?: string;Reference Files Generative Ai.Filemetadata (`docs/reference/files/generative-ai.filemetadata.md`)
Home > @google/generative-ai > FileMetadata
FileMetadata interface
Metadata to provide alongside a file upload
Signature:
export interface FileMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| displayName? | string | (Optional) | |
| mimeType | string | ||
| name? | string | (Optional) |
Reference Files Generative Ai.Filemetadata.Mimetype (`docs/reference/files/generative-ai.filemetadata.mimetype.md`)
Home > @google/generative-ai > FileMetadata > mimeType
FileMetadata.mimeType property
Signature:
mimeType: string;Reference Files Generative Ai.Filemetadata.Name (`docs/reference/files/generative-ai.filemetadata.name.md`)
Home > @google/generative-ai > FileMetadata > name
FileMetadata.name property
Signature:
name?: string;Reference Files Generative Ai.Filemetadataresponse.Createtime (`docs/reference/files/generative-ai.filemetadataresponse.createtime.md`)
Home > @google/generative-ai > FileMetadataResponse > createTime
FileMetadataResponse.createTime property
Signature:
createTime: string;Reference Files Generative Ai.Filemetadataresponse.Displayname (`docs/reference/files/generative-ai.filemetadataresponse.displayname.md`)
Home > @google/generative-ai > FileMetadataResponse > displayName
FileMetadataResponse.displayName property
Signature:
displayName?: string;Reference Files Generative Ai.Filemetadataresponse.Error (`docs/reference/files/generative-ai.filemetadataresponse.error.md`)
Home > @google/generative-ai > FileMetadataResponse > error
FileMetadataResponse.error property
Error populated if file processing has failed.
Signature:
error?: RpcStatus;Reference Files Generative Ai.Filemetadataresponse.Expirationtime (`docs/reference/files/generative-ai.filemetadataresponse.expirationtime.md`)
Home > @google/generative-ai > FileMetadataResponse > expirationTime
FileMetadataResponse.expirationTime property
Signature:
expirationTime: string;Reference Files Generative Ai.Filemetadataresponse (`docs/reference/files/generative-ai.filemetadataresponse.md`)
Home > @google/generative-ai > FileMetadataResponse
FileMetadataResponse interface
File metadata response from server.
Signature:
export interface FileMetadataResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| createTime | string | ||
| displayName? | string | (Optional) | |
| error? | RpcStatus | (Optional) Error populated if file processing has failed. | |
| expirationTime | string | ||
| mimeType | string | ||
| name | string | ||
| sha256Hash | string | ||
| sizeBytes | string | ||
| state | FileState | ||
| updateTime | string | ||
| uri | string | ||
| videoMetadata? | VideoMetadata | (Optional) Video metadata populated after processing is complete. |
Reference Files Generative Ai.Filemetadataresponse.Mimetype (`docs/reference/files/generative-ai.filemetadataresponse.mimetype.md`)
Home > @google/generative-ai > FileMetadataResponse > mimeType
FileMetadataResponse.mimeType property
Signature:
mimeType: string;Reference Files Generative Ai.Filemetadataresponse.Name (`docs/reference/files/generative-ai.filemetadataresponse.name.md`)
Home > @google/generative-ai > FileMetadataResponse > name
FileMetadataResponse.name property
Signature:
name: string;Reference Files Generative Ai.Filemetadataresponse.Sha256hash (`docs/reference/files/generative-ai.filemetadataresponse.sha256hash.md`)
Home > @google/generative-ai > FileMetadataResponse > sha256Hash
FileMetadataResponse.sha256Hash property
Signature:
sha256Hash: string;Reference Files Generative Ai.Filemetadataresponse.Sizebytes (`docs/reference/files/generative-ai.filemetadataresponse.sizebytes.md`)
Home > @google/generative-ai > FileMetadataResponse > sizeBytes
FileMetadataResponse.sizeBytes property
Signature:
sizeBytes: string;Reference Files Generative Ai.Filemetadataresponse.State (`docs/reference/files/generative-ai.filemetadataresponse.state.md`)
Home > @google/generative-ai > FileMetadataResponse > state
FileMetadataResponse.state property
Signature:
state: FileState;Reference Files Generative Ai.Filemetadataresponse.Updatetime (`docs/reference/files/generative-ai.filemetadataresponse.updatetime.md`)
Home > @google/generative-ai > FileMetadataResponse > updateTime
FileMetadataResponse.updateTime property
Signature:
updateTime: string;Reference Files Generative Ai.Filemetadataresponse.Uri (`docs/reference/files/generative-ai.filemetadataresponse.uri.md`)
Home > @google/generative-ai > FileMetadataResponse > uri
FileMetadataResponse.uri property
Signature:
uri: string;Reference Files Generative Ai.Filemetadataresponse.Videometadata (`docs/reference/files/generative-ai.filemetadataresponse.videometadata.md`)
Home > @google/generative-ai > FileMetadataResponse > videoMetadata
FileMetadataResponse.videoMetadata property
Video metadata populated after processing is complete.
Signature:
videoMetadata?: VideoMetadata;Reference Files Generative Ai.Filestate (`docs/reference/files/generative-ai.filestate.md`)
Home > @google/generative-ai > FileState
FileState enum
Processing state of the File.
Signature:
export declare enum FileStateEnumeration Members
| Member | Value | Description |
|---|---|---|
| ACTIVE | "ACTIVE" |
|
| FAILED | "FAILED" |
|
| PROCESSING | "PROCESSING" |
|
| STATE_UNSPECIFIED | "STATE_UNSPECIFIED" |
Reference Files Generative Ai.Googleaifilemanager. Constructor (`docs/reference/files/generative-ai.googleaifilemanager._constructor_.md`)
Home > @google/generative-ai > GoogleAIFileManager > (constructor)
GoogleAIFileManager.(constructor)
Constructs a new instance of the GoogleAIFileManager class
Signature:
constructor(apiKey: string, _requestOptions?: RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string | |
| _requestOptions | RequestOptions | (Optional) |
Reference Files Generative Ai.Googleaifilemanager.Apikey (`docs/reference/files/generative-ai.googleaifilemanager.apikey.md`)
Home > @google/generative-ai > GoogleAIFileManager > apiKey
GoogleAIFileManager.apiKey property
Signature:
apiKey: string;Reference Files Generative Ai.Googleaifilemanager.Deletefile (`docs/reference/files/generative-ai.googleaifilemanager.deletefile.md`)
Home > @google/generative-ai > GoogleAIFileManager > deleteFile
GoogleAIFileManager.deleteFile() method
Delete file with given ID.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
deleteFile(fileId: string, requestOptions?: SingleRequestOptions): Promise<void>;Parameters
| Parameter | Type | Description |
|---|---|---|
| fileId | string | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<void>
Reference Files Generative Ai.Googleaifilemanager.Getfile (`docs/reference/files/generative-ai.googleaifilemanager.getfile.md`)
Home > @google/generative-ai > GoogleAIFileManager > getFile
GoogleAIFileManager.getFile() method
Get metadata for file with given ID.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
getFile(fileId: string, requestOptions?: SingleRequestOptions): Promise<FileMetadataResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| fileId | string | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<FileMetadataResponse>
Reference Files Generative Ai.Googleaifilemanager.Listfiles (`docs/reference/files/generative-ai.googleaifilemanager.listfiles.md`)
Home > @google/generative-ai > GoogleAIFileManager > listFiles
GoogleAIFileManager.listFiles() method
List all uploaded files.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
listFiles(listParams?: ListParams, requestOptions?: SingleRequestOptions): Promise<ListFilesResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| listParams | ListParams | (Optional) |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<ListFilesResponse>
Reference Files Generative Ai.Googleaifilemanager (`docs/reference/files/generative-ai.googleaifilemanager.md`)
Home > @google/generative-ai > GoogleAIFileManager
GoogleAIFileManager class
Class for managing GoogleAI file uploads.
Signature:
export declare class GoogleAIFileManagerConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, _requestOptions) | Constructs a new instance of the GoogleAIFileManager class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiKey | string |
Methods
| Method | Modifiers | Description |
|---|---|---|
| deleteFile(fileId, requestOptions) | Delete file with given ID.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. | |
| getFile(fileId, requestOptions) | Get metadata for file with given ID.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. | |
| listFiles(listParams, requestOptions) | List all uploaded files.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. | |
| uploadFile(filePath, fileMetadata, requestOptions) | Upload a file.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. |
Reference Files Generative Ai.Googleaifilemanager.Uploadfile (`docs/reference/files/generative-ai.googleaifilemanager.uploadfile.md`)
Home > @google/generative-ai > GoogleAIFileManager > uploadFile
GoogleAIFileManager.uploadFile() method
Upload a file.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
uploadFile(filePath: string, fileMetadata: FileMetadata, requestOptions?: SingleRequestOptions): Promise<UploadFileResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| filePath | string | |
| fileMetadata | FileMetadata | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<UploadFileResponse>
Reference Files Generative Ai.Listfilesresponse.Files (`docs/reference/files/generative-ai.listfilesresponse.files.md`)
Home > @google/generative-ai > ListFilesResponse > files
ListFilesResponse.files property
Signature:
files: FileMetadataResponse[];Reference Files Generative Ai.Listfilesresponse (`docs/reference/files/generative-ai.listfilesresponse.md`)
Home > @google/generative-ai > ListFilesResponse
ListFilesResponse interface
Response from calling GoogleAIFileManager.listFiles()
Signature:
export interface ListFilesResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| files | FileMetadataResponse[] | ||
| nextPageToken? | string | (Optional) |
Reference Files Generative Ai.Listfilesresponse.Nextpagetoken (`docs/reference/files/generative-ai.listfilesresponse.nextpagetoken.md`)
Home > @google/generative-ai > ListFilesResponse > nextPageToken
ListFilesResponse.nextPageToken property
Signature:
nextPageToken?: string;Reference Files Generative Ai.Listparams (`docs/reference/files/generative-ai.listparams.md`)
Home > @google/generative-ai > ListParams
ListParams interface
Params to pass to GoogleAIFileManager.listFiles()
Signature:
export interface ListParamsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| pageSize? | number | (Optional) | |
| pageToken? | string | (Optional) |
Reference Files Generative Ai.Listparams.Pagesize (`docs/reference/files/generative-ai.listparams.pagesize.md`)
Home > @google/generative-ai > ListParams > pageSize
ListParams.pageSize property
Signature:
pageSize?: number;Reference Files Generative Ai.Listparams.Pagetoken (`docs/reference/files/generative-ai.listparams.pagetoken.md`)
Home > @google/generative-ai > ListParams > pageToken
ListParams.pageToken property
Signature:
pageToken?: string;Reference Files Generative Ai (`docs/reference/files/generative-ai.md`)
generative-ai package
Classes
| Class | Description |
|---|---|
| GoogleAIFileManager | Class for managing GoogleAI file uploads. |
Enumerations
| Enumeration | Description |
|---|---|
| FileState | Processing state of the File. |
Interfaces
| Interface | Description |
|---|---|
| ErrorDetails | Details object that may be included in an error response. |
| FileMetadata | Metadata to provide alongside a file upload |
| FileMetadataResponse | File metadata response from server. |
| ListFilesResponse | Response from calling GoogleAIFileManager.listFiles() |
| ListParams | Params to pass to GoogleAIFileManager.listFiles() |
| RequestOptions | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
| RpcStatus | Standard RPC error status object. |
| SingleRequestOptions | Params passed to atomic asynchronous operations. |
| UploadFileResponse | Response from calling GoogleAIFileManager.uploadFile() |
| VideoMetadata | Metadata populated when video has been processed. |
Reference Files Generative Ai.Requestoptions.Apiclient (`docs/reference/files/generative-ai.requestoptions.apiclient.md`)
Home > @google/generative-ai > RequestOptions > apiClient
RequestOptions.apiClient property
Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs.
Signature:
apiClient?: string;Reference Files Generative Ai.Requestoptions.Apiversion (`docs/reference/files/generative-ai.requestoptions.apiversion.md`)
Home > @google/generative-ai > RequestOptions > apiVersion
RequestOptions.apiVersion property
Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version.
Signature:
apiVersion?: string;Reference Files Generative Ai.Requestoptions.Baseurl (`docs/reference/files/generative-ai.requestoptions.baseurl.md`)
Home > @google/generative-ai > RequestOptions > baseUrl
RequestOptions.baseUrl property
Base endpoint url. Defaults to "https://generativelanguage.googleapis.com"
Signature:
baseUrl?: string;Reference Files Generative Ai.Requestoptions.Customheaders (`docs/reference/files/generative-ai.requestoptions.customheaders.md`)
Home > @google/generative-ai > RequestOptions > customHeaders
RequestOptions.customHeaders property
Custom HTTP request headers.
Signature:
customHeaders?: Headers | Record<string, string>;Reference Files Generative Ai.Requestoptions (`docs/reference/files/generative-ai.requestoptions.md`)
Home > @google/generative-ai > RequestOptions
RequestOptions interface
Params passed to getGenerativeModel() or GoogleAIFileManager().
Signature:
export interface RequestOptionsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiClient? | string | (Optional) Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs. | |
| apiVersion? | string | (Optional) Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version. | |
| baseUrl? | string | (Optional) Base endpoint url. Defaults to "https://generativelanguage.googleapis.com" | |
| customHeaders? | Headers | Record<string, string> | (Optional) Custom HTTP request headers. | |
| timeout? | number | (Optional) Request timeout in milliseconds. |
Reference Files Generative Ai.Requestoptions.Timeout (`docs/reference/files/generative-ai.requestoptions.timeout.md`)
Home > @google/generative-ai > RequestOptions > timeout
RequestOptions.timeout property
Request timeout in milliseconds.
Signature:
timeout?: number;Reference Files Generative Ai.Rpcstatus.Code (`docs/reference/files/generative-ai.rpcstatus.code.md`)
Home > @google/generative-ai > RpcStatus > code
RpcStatus.code property
Error status code
Signature:
code: number;Reference Files Generative Ai.Rpcstatus.Details (`docs/reference/files/generative-ai.rpcstatus.details.md`)
Home > @google/generative-ai > RpcStatus > details
RpcStatus.details property
A list of messages that carry the error details.
Signature:
details?: ErrorDetails[];Reference Files Generative Ai.Rpcstatus (`docs/reference/files/generative-ai.rpcstatus.md`)
Home > @google/generative-ai > RpcStatus
RpcStatus interface
Standard RPC error status object.
Signature:
export interface RpcStatusProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| code | number | Error status code | |
| details? | ErrorDetails[] | (Optional) A list of messages that carry the error details. | |
| message | string | A developer-facing error message. |
Reference Files Generative Ai.Rpcstatus.Message (`docs/reference/files/generative-ai.rpcstatus.message.md`)
Home > @google/generative-ai > RpcStatus > message
RpcStatus.message property
A developer-facing error message.
Signature:
message: string;Reference Files Generative Ai.Singlerequestoptions (`docs/reference/files/generative-ai.singlerequestoptions.md`)
Home > @google/generative-ai > SingleRequestOptions
SingleRequestOptions interface
Params passed to atomic asynchronous operations.
Signature:
export interface SingleRequestOptions extends RequestOptionsExtends: RequestOptions
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| signal? | AbortSignal | (Optional) An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided, and if the timeout occurs first. |
Reference Files Generative Ai.Singlerequestoptions.Signal (`docs/reference/files/generative-ai.singlerequestoptions.signal.md`)
Home > @google/generative-ai > SingleRequestOptions > signal
SingleRequestOptions.signal property
An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided, and if the timeout occurs first.
Signature:
signal?: AbortSignal;Reference Files Generative Ai.Uploadfileresponse.File (`docs/reference/files/generative-ai.uploadfileresponse.file.md`)
Home > @google/generative-ai > UploadFileResponse > file
UploadFileResponse.file property
Signature:
file: FileMetadataResponse;Reference Files Generative Ai.Uploadfileresponse (`docs/reference/files/generative-ai.uploadfileresponse.md`)
Home > @google/generative-ai > UploadFileResponse
UploadFileResponse interface
Response from calling GoogleAIFileManager.uploadFile()
Signature:
export interface UploadFileResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| file | FileMetadataResponse |
Reference Files Generative Ai.Videometadata (`docs/reference/files/generative-ai.videometadata.md`)
Home > @google/generative-ai > VideoMetadata
VideoMetadata interface
Metadata populated when video has been processed.
Signature:
export interface VideoMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| videoDuration | string | The video duration in protobuf Duration format. |
Reference Files Generative Ai.Videometadata.Videoduration (`docs/reference/files/generative-ai.videometadata.videoduration.md`)
Home > @google/generative-ai > VideoMetadata > videoDuration
VideoMetadata.videoDuration property
The video duration in protobuf Duration format.
Signature:
videoDuration: string;Reference Main Generative Ai.Arrayschema.Items (`docs/reference/main/generative-ai.arrayschema.items.md`)
Home > @google/generative-ai > ArraySchema > items
ArraySchema.items property
A schema describing the entries in the array.
Signature:
items: Schema;Reference Main Generative Ai.Arrayschema.Maxitems (`docs/reference/main/generative-ai.arrayschema.maxitems.md`)
Home > @google/generative-ai > ArraySchema > maxItems
ArraySchema.maxItems property
The maximum number of items in the array.
Signature:
maxItems?: number;Reference Main Generative Ai.Arrayschema (`docs/reference/main/generative-ai.arrayschema.md`)
Home > @google/generative-ai > ArraySchema
ArraySchema interface
Describes an array, an ordered list of values.
Signature:
export interface ArraySchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| items | Schema | A schema describing the entries in the array. | |
| maxItems? | number | (Optional) The maximum number of items in the array. | |
| minItems? | number | (Optional) The minimum number of items in the array. | |
| type | typeof SchemaType.ARRAY |
Reference Main Generative Ai.Arrayschema.Minitems (`docs/reference/main/generative-ai.arrayschema.minitems.md`)
Home > @google/generative-ai > ArraySchema > minItems
ArraySchema.minItems property
The minimum number of items in the array.
Signature:
minItems?: number;Reference Main Generative Ai.Arrayschema.Type (`docs/reference/main/generative-ai.arrayschema.type.md`)
Home > @google/generative-ai > ArraySchema > type
ArraySchema.type property
Signature:
type: typeof SchemaType.ARRAY;Reference Main Generative Ai.Baseparams.Generationconfig (`docs/reference/main/generative-ai.baseparams.generationconfig.md`)
Home > @google/generative-ai > BaseParams > generationConfig
BaseParams.generationConfig property
Signature:
generationConfig?: GenerationConfig;Reference Main Generative Ai.Baseparams (`docs/reference/main/generative-ai.baseparams.md`)
Home > @google/generative-ai > BaseParams
BaseParams interface
Base parameters for a number of methods.
Signature:
export interface BaseParamsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| generationConfig? | GenerationConfig | (Optional) | |
| safetySettings? | SafetySetting[] | (Optional) |
Reference Main Generative Ai.Baseparams.Safetysettings (`docs/reference/main/generative-ai.baseparams.safetysettings.md`)
Home > @google/generative-ai > BaseParams > safetySettings
BaseParams.safetySettings property
Signature:
safetySettings?: SafetySetting[];Reference Main Generative Ai.Batchembedcontentsrequest (`docs/reference/main/generative-ai.batchembedcontentsrequest.md`)
Home > @google/generative-ai > BatchEmbedContentsRequest
BatchEmbedContentsRequest interface
Params for calling GenerativeModel.batchEmbedContents()
Signature:
export interface BatchEmbedContentsRequestProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| requests | EmbedContentRequest[] |
Reference Main Generative Ai.Batchembedcontentsrequest.Requests (`docs/reference/main/generative-ai.batchembedcontentsrequest.requests.md`)
Home > @google/generative-ai > BatchEmbedContentsRequest > requests
BatchEmbedContentsRequest.requests property
Signature:
requests: EmbedContentRequest[];Reference Main Generative Ai.Batchembedcontentsresponse.Embeddings (`docs/reference/main/generative-ai.batchembedcontentsresponse.embeddings.md`)
Home > @google/generative-ai > BatchEmbedContentsResponse > embeddings
BatchEmbedContentsResponse.embeddings property
Signature:
embeddings: ContentEmbedding[];Reference Main Generative Ai.Batchembedcontentsresponse (`docs/reference/main/generative-ai.batchembedcontentsresponse.md`)
Home > @google/generative-ai > BatchEmbedContentsResponse
BatchEmbedContentsResponse interface
Response from calling GenerativeModel.batchEmbedContents().
Signature:
export interface BatchEmbedContentsResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| embeddings | ContentEmbedding[] |
Reference Main Generative Ai.Blockreason (`docs/reference/main/generative-ai.blockreason.md`)
Home > @google/generative-ai > BlockReason
BlockReason enum
Reason that a prompt was blocked.
Signature:
export declare enum BlockReasonEnumeration Members
| Member | Value | Description |
|---|---|---|
| BLOCKED_REASON_UNSPECIFIED | "BLOCKED_REASON_UNSPECIFIED" |
|
| OTHER | "OTHER" |
|
| SAFETY | "SAFETY" |
Reference Main Generative Ai.Booleanschema (`docs/reference/main/generative-ai.booleanschema.md`)
Home > @google/generative-ai > BooleanSchema
BooleanSchema interface
Describes a boolean, either 'true' or 'false'.
Signature:
export interface BooleanSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| type | typeof SchemaType.BOOLEAN |
Reference Main Generative Ai.Booleanschema.Type (`docs/reference/main/generative-ai.booleanschema.type.md`)
Home > @google/generative-ai > BooleanSchema > type
BooleanSchema.type property
Signature:
type: typeof SchemaType.BOOLEAN;Reference Main Generative Ai.Cachedcontent.Createtime (`docs/reference/main/generative-ai.cachedcontent.createtime.md`)
Home > @google/generative-ai > CachedContent > createTime
CachedContent.createTime property
CachedContent creation time in ISO string format.
Signature:
createTime?: string;Reference Main Generative Ai.Cachedcontent (`docs/reference/main/generative-ai.cachedcontent.md`)
Home > @google/generative-ai > CachedContent
CachedContent interface
Describes CachedContent interface for sending to the server (if creating) or received from the server (using getters or list methods).
Signature:
export interface CachedContent extends CachedContentBaseExtends: CachedContentBase
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| createTime? | string | (Optional) CachedContent creation time in ISO string format. |
|
| name? | string | (Optional) | |
| ttl? | string | (Optional) protobuf.Duration format (ex. "3.0001s"). | |
| updateTime? | string | (Optional) CachedContent update time in ISO string format. |
Reference Main Generative Ai.Cachedcontent.Name (`docs/reference/main/generative-ai.cachedcontent.name.md`)
Home > @google/generative-ai > CachedContent > name
CachedContent.name property
Signature:
name?: string;Reference Main Generative Ai.Cachedcontent.Ttl (`docs/reference/main/generative-ai.cachedcontent.ttl.md`)
Home > @google/generative-ai > CachedContent > ttl
CachedContent.ttl property
protobuf.Duration format (ex. "3.0001s").
Signature:
ttl?: string;Reference Main Generative Ai.Cachedcontent.Updatetime (`docs/reference/main/generative-ai.cachedcontent.updatetime.md`)
Home > @google/generative-ai > CachedContent > updateTime
CachedContent.updateTime property
CachedContent update time in ISO string format.
Signature:
updateTime?: string;Reference Main Generative Ai.Cachedcontentbase.Contents (`docs/reference/main/generative-ai.cachedcontentbase.contents.md`)
Home > @google/generative-ai > CachedContentBase > contents
CachedContentBase.contents property
Signature:
contents: Content[];Reference Main Generative Ai.Cachedcontentbase.Displayname (`docs/reference/main/generative-ai.cachedcontentbase.displayname.md`)
Home > @google/generative-ai > CachedContentBase > displayName
CachedContentBase.displayName property
Signature:
displayName?: string;Reference Main Generative Ai.Cachedcontentbase.Expiretime (`docs/reference/main/generative-ai.cachedcontentbase.expiretime.md`)
Home > @google/generative-ai > CachedContentBase > expireTime
CachedContentBase.expireTime property
Expiration time in ISO string format. Specify either this or ttlSeconds when creating a CachedContent.
Signature:
expireTime?: string;Reference Main Generative Ai.Cachedcontentbase (`docs/reference/main/generative-ai.cachedcontentbase.md`)
Home > @google/generative-ai > CachedContentBase
CachedContentBase interface
Signature:
export interface CachedContentBaseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| contents | Content[] | ||
| displayName? | string | (Optional) | |
| expireTime? | string | (Optional) Expiration time in ISO string format. Specify either this or ttlSeconds when creating a CachedContent. |
|
| model? | string | (Optional) | |
| systemInstruction? | string | Part | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Reference Main Generative Ai.Cachedcontentbase.Model (`docs/reference/main/generative-ai.cachedcontentbase.model.md`)
Home > @google/generative-ai > CachedContentBase > model
CachedContentBase.model property
Signature:
model?: string;Reference Main Generative Ai.Cachedcontentbase.Systeminstruction (`docs/reference/main/generative-ai.cachedcontentbase.systeminstruction.md`)
Home > @google/generative-ai > CachedContentBase > systemInstruction
CachedContentBase.systemInstruction property
Signature:
systemInstruction?: string | Part | Content;Reference Main Generative Ai.Cachedcontentbase.Toolconfig (`docs/reference/main/generative-ai.cachedcontentbase.toolconfig.md`)
Home > @google/generative-ai > CachedContentBase > toolConfig
CachedContentBase.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Main Generative Ai.Cachedcontentbase.Tools (`docs/reference/main/generative-ai.cachedcontentbase.tools.md`)
Home > @google/generative-ai > CachedContentBase > tools
CachedContentBase.tools property
Signature:
tools?: Tool[];Reference Main Generative Ai.Chatsession. Constructor (`docs/reference/main/generative-ai.chatsession._constructor_.md`)
Home > @google/generative-ai > ChatSession > (constructor)
ChatSession.(constructor)
Constructs a new instance of the ChatSession class
Signature:
constructor(apiKey: string, model: string, params?: StartChatParams, _requestOptions?: RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string | |
| model | string | |
| params | StartChatParams | (Optional) |
| _requestOptions | RequestOptions | (Optional) |
Reference Main Generative Ai.Chatsession.Gethistory (`docs/reference/main/generative-ai.chatsession.gethistory.md`)
Home > @google/generative-ai > ChatSession > getHistory
ChatSession.getHistory() method
Gets the chat history so far. Blocked prompts are not added to history. Blocked candidates are not added to history, nor are the prompts that generated them.
Signature:
getHistory(): Promise<Content[]>;Returns:
Promise<Content[]>
Reference Main Generative Ai.Chatsession (`docs/reference/main/generative-ai.chatsession.md`)
Home > @google/generative-ai > ChatSession
ChatSession class
ChatSession class that enables sending chat messages and stores history of sent and received messages so far.
Signature:
export declare class ChatSessionConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, model, params, _requestOptions) | Constructs a new instance of the ChatSession class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| model | string | ||
| params? | StartChatParams | (Optional) |
Methods
| Method | Modifiers | Description |
|---|---|---|
| getHistory() | Gets the chat history so far. Blocked prompts are not added to history. Blocked candidates are not added to history, nor are the prompts that generated them. | |
| sendMessage(request, requestOptions) | Sends a chat message and receives a non-streaming GenerateContentResult.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| sendMessageStream(request, requestOptions) | Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). |
Reference Main Generative Ai.Chatsession.Model (`docs/reference/main/generative-ai.chatsession.model.md`)
Home > @google/generative-ai > ChatSession > model
ChatSession.model property
Signature:
model: string;Reference Main Generative Ai.Chatsession.Params (`docs/reference/main/generative-ai.chatsession.params.md`)
Home > @google/generative-ai > ChatSession > params
ChatSession.params property
Signature:
params?: StartChatParams;Reference Main Generative Ai.Chatsession.Sendmessage (`docs/reference/main/generative-ai.chatsession.sendmessage.md`)
Home > @google/generative-ai > ChatSession > sendMessage
ChatSession.sendMessage() method
Sends a chat message and receives a non-streaming GenerateContentResult.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
sendMessage(request: string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<GenerateContentResult>
Reference Main Generative Ai.Chatsession.Sendmessagestream (`docs/reference/main/generative-ai.chatsession.sendmessagestream.md`)
Home > @google/generative-ai > ChatSession > sendMessageStream
ChatSession.sendMessageStream() method
Sends a chat message and receives the response as a GenerateContentStreamResult containing an iterable stream and a response promise.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
sendMessageStream(request: string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<GenerateContentStreamResult>
Reference Main Generative Ai.Citationmetadata.Citationsources (`docs/reference/main/generative-ai.citationmetadata.citationsources.md`)
Home > @google/generative-ai > CitationMetadata > citationSources
CitationMetadata.citationSources property
Signature:
citationSources: CitationSource[];Reference Main Generative Ai.Citationmetadata (`docs/reference/main/generative-ai.citationmetadata.md`)
Home > @google/generative-ai > CitationMetadata
CitationMetadata interface
Citation metadata that may be found on a GenerateContentCandidate.
Signature:
export interface CitationMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| citationSources | CitationSource[] |
Reference Main Generative Ai.Citationsource.License (`docs/reference/main/generative-ai.citationsource.license.md`)
Home > @google/generative-ai > CitationSource > license
CitationSource.license property
Signature:
license?: string;Reference Main Generative Ai.Citationsource (`docs/reference/main/generative-ai.citationsource.md`)
Home > @google/generative-ai > CitationSource
CitationSource interface
A single citation source.
Signature:
export interface CitationSourceProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| endIndex? | number | (Optional) | |
| license? | string | (Optional) | |
| startIndex? | number | (Optional) | |
| uri? | string | (Optional) |
Reference Main Generative Ai.Citationsource.Uri (`docs/reference/main/generative-ai.citationsource.uri.md`)
Home > @google/generative-ai > CitationSource > uri
CitationSource.uri property
Signature:
uri?: string;Reference Main Generative Ai.Codeexecutionresult (`docs/reference/main/generative-ai.codeexecutionresult.md`)
Home > @google/generative-ai > CodeExecutionResult
CodeExecutionResult interface
Result of executing the ExecutableCode. Only generated when using code execution, and always follows a Part containing the ExecutableCode.
Signature:
export interface CodeExecutionResultProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| outcome | Outcome | Outcome of the code execution. | |
| output | string | Contains stdout when code execution is successful, stderr or other description otherwise. |
Reference Main Generative Ai.Codeexecutionresult.Outcome (`docs/reference/main/generative-ai.codeexecutionresult.outcome.md`)
Home > @google/generative-ai > CodeExecutionResult > outcome
CodeExecutionResult.outcome property
Outcome of the code execution.
Signature:
outcome: Outcome;Reference Main Generative Ai.Codeexecutionresult.Output (`docs/reference/main/generative-ai.codeexecutionresult.output.md`)
Home > @google/generative-ai > CodeExecutionResult > output
CodeExecutionResult.output property
Contains stdout when code execution is successful, stderr or other description otherwise.
Signature:
output: string;Reference Main Generative Ai.Codeexecutionresultpart.Codeexecutionresult (`docs/reference/main/generative-ai.codeexecutionresultpart.codeexecutionresult.md`)
Home > @google/generative-ai > CodeExecutionResultPart > codeExecutionResult
CodeExecutionResultPart.codeExecutionResult property
Signature:
codeExecutionResult: CodeExecutionResult;Reference Main Generative Ai.Codeexecutionresultpart.Executablecode (`docs/reference/main/generative-ai.codeexecutionresultpart.executablecode.md`)
Home > @google/generative-ai > CodeExecutionResultPart > executableCode
CodeExecutionResultPart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Codeexecutionresultpart.Filedata (`docs/reference/main/generative-ai.codeexecutionresultpart.filedata.md`)
Home > @google/generative-ai > CodeExecutionResultPart > fileData
CodeExecutionResultPart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Codeexecutionresultpart.Functioncall (`docs/reference/main/generative-ai.codeexecutionresultpart.functioncall.md`)
Home > @google/generative-ai > CodeExecutionResultPart > functionCall
CodeExecutionResultPart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Codeexecutionresultpart.Functionresponse (`docs/reference/main/generative-ai.codeexecutionresultpart.functionresponse.md`)
Home > @google/generative-ai > CodeExecutionResultPart > functionResponse
CodeExecutionResultPart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Codeexecutionresultpart.Inlinedata (`docs/reference/main/generative-ai.codeexecutionresultpart.inlinedata.md`)
Home > @google/generative-ai > CodeExecutionResultPart > inlineData
CodeExecutionResultPart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Codeexecutionresultpart (`docs/reference/main/generative-ai.codeexecutionresultpart.md`)
Home > @google/generative-ai > CodeExecutionResultPart
CodeExecutionResultPart interface
Content part containing the result of executed code.
Signature:
export interface CodeExecutionResultPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult | CodeExecutionResult | ||
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Main Generative Ai.Codeexecutionresultpart.Text (`docs/reference/main/generative-ai.codeexecutionresultpart.text.md`)
Home > @google/generative-ai > CodeExecutionResultPart > text
CodeExecutionResultPart.text property
Signature:
text?: never;Reference Main Generative Ai.Codeexecutiontool.Codeexecution (`docs/reference/main/generative-ai.codeexecutiontool.codeexecution.md`)
Home > @google/generative-ai > CodeExecutionTool > codeExecution
CodeExecutionTool.codeExecution property
Provide an empty object to enable code execution. This field may have subfields added in the future.
Signature:
codeExecution: {};Reference Main Generative Ai.Codeexecutiontool (`docs/reference/main/generative-ai.codeexecutiontool.md`)
Home > @google/generative-ai > CodeExecutionTool
CodeExecutionTool interface
Enables the model to execute code as part of generation.
Signature:
export interface CodeExecutionToolProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecution | {} | Provide an empty object to enable code execution. This field may have subfields added in the future. |
Reference Main Generative Ai.Content (`docs/reference/main/generative-ai.content.md`)
Home > @google/generative-ai > Content
Content interface
Content type for both prompts and response candidates.
Signature:
export interface ContentProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| parts | Part[] | ||
| role | string |
Reference Main Generative Ai.Content.Parts (`docs/reference/main/generative-ai.content.parts.md`)
Home > @google/generative-ai > Content > parts
Content.parts property
Signature:
parts: Part[];Reference Main Generative Ai.Content.Role (`docs/reference/main/generative-ai.content.role.md`)
Home > @google/generative-ai > Content > role
Content.role property
Signature:
role: string;Reference Main Generative Ai.Contentembedding (`docs/reference/main/generative-ai.contentembedding.md`)
Home > @google/generative-ai > ContentEmbedding
ContentEmbedding interface
A single content embedding.
Signature:
export interface ContentEmbeddingProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| values | number[] |
Reference Main Generative Ai.Contentembedding.Values (`docs/reference/main/generative-ai.contentembedding.values.md`)
Home > @google/generative-ai > ContentEmbedding > values
ContentEmbedding.values property
Signature:
values: number[];Reference Main Generative Ai.Counttokensrequest.Contents (`docs/reference/main/generative-ai.counttokensrequest.contents.md`)
Home > @google/generative-ai > CountTokensRequest > contents
CountTokensRequest.contents property
Signature:
contents?: Content[];Reference Main Generative Ai.Counttokensrequest.Generatecontentrequest (`docs/reference/main/generative-ai.counttokensrequest.generatecontentrequest.md`)
Home > @google/generative-ai > CountTokensRequest > generateContentRequest
CountTokensRequest.generateContentRequest property
Signature:
generateContentRequest?: GenerateContentRequest;Reference Main Generative Ai.Counttokensrequest (`docs/reference/main/generative-ai.counttokensrequest.md`)
Home > @google/generative-ai > CountTokensRequest
CountTokensRequest interface
Params for calling GenerativeModel.countTokens().
The request must contain either a Content array or a GenerateContentRequest, but not both. If both are provided then a GoogleGenerativeAIRequestInputError is thrown.
Signature:
export interface CountTokensRequestProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| contents? | Content[] | (Optional) | |
| generateContentRequest? | GenerateContentRequest | (Optional) |
Reference Main Generative Ai.Counttokensresponse (`docs/reference/main/generative-ai.counttokensresponse.md`)
Home > @google/generative-ai > CountTokensResponse
CountTokensResponse interface
Response from calling GenerativeModel.countTokens().
Signature:
export interface CountTokensResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| totalTokens | number |
Reference Main Generative Ai.Counttokensresponse.Totaltokens (`docs/reference/main/generative-ai.counttokensresponse.totaltokens.md`)
Home > @google/generative-ai > CountTokensResponse > totalTokens
CountTokensResponse.totalTokens property
Signature:
totalTokens: number;Reference Main Generative Ai.Dynamicretrievalconfig.Dynamicthreshold (`docs/reference/main/generative-ai.dynamicretrievalconfig.dynamicthreshold.md`)
Home > @google/generative-ai > DynamicRetrievalConfig > dynamicThreshold
DynamicRetrievalConfig.dynamicThreshold property
The threshold to be used in dynamic retrieval. If not set, a system default value is used.
Signature:
dynamicThreshold?: number;Reference Main Generative Ai.Dynamicretrievalconfig (`docs/reference/main/generative-ai.dynamicretrievalconfig.md`)
Home > @google/generative-ai > DynamicRetrievalConfig
DynamicRetrievalConfig interface
Specifies the dynamic retrieval configuration for the given source.
Signature:
export declare interface DynamicRetrievalConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| dynamicThreshold? | number | (Optional) The threshold to be used in dynamic retrieval. If not set, a system default value is used. | |
| mode? | DynamicRetrievalMode | (Optional) The mode of the predictor to be used in dynamic retrieval. |
Reference Main Generative Ai.Dynamicretrievalconfig.Mode (`docs/reference/main/generative-ai.dynamicretrievalconfig.mode.md`)
Home > @google/generative-ai > DynamicRetrievalConfig > mode
DynamicRetrievalConfig.mode property
The mode of the predictor to be used in dynamic retrieval.
Signature:
mode?: DynamicRetrievalMode;Reference Main Generative Ai.Dynamicretrievalmode (`docs/reference/main/generative-ai.dynamicretrievalmode.md`)
Home > @google/generative-ai > DynamicRetrievalMode
DynamicRetrievalMode enum
The mode of the predictor to be used in dynamic retrieval.
Signature:
export declare enum DynamicRetrievalModeEnumeration Members
| Member | Value | Description |
|---|---|---|
| MODE_DYNAMIC | "MODE_DYNAMIC" |
|
| MODE_UNSPECIFIED | "MODE_UNSPECIFIED" |
Reference Main Generative Ai.Embedcontentrequest.Content (`docs/reference/main/generative-ai.embedcontentrequest.content.md`)
Home > @google/generative-ai > EmbedContentRequest > content
EmbedContentRequest.content property
Signature:
content: Content;Reference Main Generative Ai.Embedcontentrequest (`docs/reference/main/generative-ai.embedcontentrequest.md`)
Home > @google/generative-ai > EmbedContentRequest
EmbedContentRequest interface
Params for calling GenerativeModel.embedContent()
Signature:
export interface EmbedContentRequestProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| content | Content | ||
| taskType? | TaskType | (Optional) | |
| title? | string | (Optional) |
Reference Main Generative Ai.Embedcontentrequest.Tasktype (`docs/reference/main/generative-ai.embedcontentrequest.tasktype.md`)
Home > @google/generative-ai > EmbedContentRequest > taskType
EmbedContentRequest.taskType property
Signature:
taskType?: TaskType;Reference Main Generative Ai.Embedcontentrequest.Title (`docs/reference/main/generative-ai.embedcontentrequest.title.md`)
Home > @google/generative-ai > EmbedContentRequest > title
EmbedContentRequest.title property
Signature:
title?: string;Reference Main Generative Ai.Embedcontentresponse.Embedding (`docs/reference/main/generative-ai.embedcontentresponse.embedding.md`)
Home > @google/generative-ai > EmbedContentResponse > embedding
EmbedContentResponse.embedding property
Signature:
embedding: ContentEmbedding;Reference Main Generative Ai.Embedcontentresponse (`docs/reference/main/generative-ai.embedcontentresponse.md`)
Home > @google/generative-ai > EmbedContentResponse
EmbedContentResponse interface
Response from calling GenerativeModel.embedContent().
Signature:
export interface EmbedContentResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| embedding | ContentEmbedding |
Reference Main Generative Ai.Enhancedgeneratecontentresponse.Functioncall (`docs/reference/main/generative-ai.enhancedgeneratecontentresponse.functioncall.md`)
Home > @google/generative-ai > EnhancedGenerateContentResponse > functionCall
EnhancedGenerateContentResponse.functionCall property
Warning: This API is now obsolete.
- use
functionCalls()instead
Deprecated: use functionCalls() instead.
Signature:
functionCall: () => FunctionCall | undefined;Reference Main Generative Ai.Enhancedgeneratecontentresponse.Functioncalls (`docs/reference/main/generative-ai.enhancedgeneratecontentresponse.functioncalls.md`)
Home > @google/generative-ai > EnhancedGenerateContentResponse > functionCalls
EnhancedGenerateContentResponse.functionCalls property
Returns function calls found in any Parts of the first candidate of the response, if available. Throws if the prompt or candidate was blocked.
Signature:
functionCalls: () => FunctionCall[] | undefined;Reference Main Generative Ai.Enhancedgeneratecontentresponse (`docs/reference/main/generative-ai.enhancedgeneratecontentresponse.md`)
Home > @google/generative-ai > EnhancedGenerateContentResponse
EnhancedGenerateContentResponse interface
Response object wrapped with helper methods.
Signature:
export interface EnhancedGenerateContentResponse extends GenerateContentResponseExtends: GenerateContentResponse
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| functionCall | () => FunctionCall | undefined | Deprecated: use functionCalls() instead. |
|
| functionCalls | () => FunctionCall[] | undefined | Returns function calls found in any Parts of the first candidate of the response, if available. Throws if the prompt or candidate was blocked. |
|
| text | () => string | Returns the text string assembled from all Parts of the first candidate of the response, if available. Throws if the prompt or candidate was blocked. |
Reference Main Generative Ai.Enhancedgeneratecontentresponse.Text (`docs/reference/main/generative-ai.enhancedgeneratecontentresponse.text.md`)
Home > @google/generative-ai > EnhancedGenerateContentResponse > text
EnhancedGenerateContentResponse.text property
Returns the text string assembled from all Parts of the first candidate of the response, if available. Throws if the prompt or candidate was blocked.
Signature:
text: () => string;Reference Main Generative Ai.Enumstringschema.Enum (`docs/reference/main/generative-ai.enumstringschema.enum.md`)
Home > @google/generative-ai > EnumStringSchema > enum
EnumStringSchema.enum property
Possible values for this enum
Signature:
enum: string[];Reference Main Generative Ai.Enumstringschema.Format (`docs/reference/main/generative-ai.enumstringschema.format.md`)
Home > @google/generative-ai > EnumStringSchema > format
EnumStringSchema.format property
Signature:
format: "enum";Reference Main Generative Ai.Enumstringschema (`docs/reference/main/generative-ai.enumstringschema.md`)
Home > @google/generative-ai > EnumStringSchema
EnumStringSchema interface
Describes a string enum
Signature:
export interface EnumStringSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| enum | string[] | Possible values for this enum | |
| format | "enum" | ||
| type | typeof SchemaType.STRING |
Reference Main Generative Ai.Enumstringschema.Type (`docs/reference/main/generative-ai.enumstringschema.type.md`)
Home > @google/generative-ai > EnumStringSchema > type
EnumStringSchema.type property
Signature:
type: typeof SchemaType.STRING;Reference Main Generative Ai.Errordetails. Type (`docs/reference/main/generative-ai.errordetails.__type_.md`)
Home > @google/generative-ai > ErrorDetails > "@type"
ErrorDetails."@type" property
Signature:
"@type"?: string;Reference Main Generative Ai.Errordetails.Domain (`docs/reference/main/generative-ai.errordetails.domain.md`)
Home > @google/generative-ai > ErrorDetails > domain
ErrorDetails.domain property
Signature:
domain?: string;Reference Main Generative Ai.Errordetails (`docs/reference/main/generative-ai.errordetails.md`)
Home > @google/generative-ai > ErrorDetails
ErrorDetails interface
Details object that may be included in an error response.
Signature:
export interface ErrorDetailsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| "@type"? | string | (Optional) | |
| domain? | string | (Optional) | |
| metadata? | Record<string, unknown> | (Optional) | |
| reason? | string | (Optional) |
Reference Main Generative Ai.Errordetails.Metadata (`docs/reference/main/generative-ai.errordetails.metadata.md`)
Home > @google/generative-ai > ErrorDetails > metadata
ErrorDetails.metadata property
Signature:
metadata?: Record<string, unknown>;Reference Main Generative Ai.Errordetails.Reason (`docs/reference/main/generative-ai.errordetails.reason.md`)
Home > @google/generative-ai > ErrorDetails > reason
ErrorDetails.reason property
Signature:
reason?: string;Reference Main Generative Ai.Executablecode.Code (`docs/reference/main/generative-ai.executablecode.code.md`)
Home > @google/generative-ai > ExecutableCode > code
ExecutableCode.code property
The code to be executed.
Signature:
code: string;Reference Main Generative Ai.Executablecode.Language (`docs/reference/main/generative-ai.executablecode.language.md`)
Home > @google/generative-ai > ExecutableCode > language
ExecutableCode.language property
Programming language of the code.
Signature:
language: ExecutableCodeLanguage;Reference Main Generative Ai.Executablecode (`docs/reference/main/generative-ai.executablecode.md`)
Home > @google/generative-ai > ExecutableCode
ExecutableCode interface
Code generated by the model that is meant to be executed, where the result is returned to the model. Only generated when using the code execution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
Signature:
export interface ExecutableCodeProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| code | string | The code to be executed. | |
| language | ExecutableCodeLanguage | Programming language of the code. |
Reference Main Generative Ai.Executablecodelanguage (`docs/reference/main/generative-ai.executablecodelanguage.md`)
Home > @google/generative-ai > ExecutableCodeLanguage
ExecutableCodeLanguage enum
Signature:
export declare enum ExecutableCodeLanguageEnumeration Members
| Member | Value | Description |
|---|---|---|
| LANGUAGE_UNSPECIFIED | "language_unspecified" |
|
| PYTHON | "python" |
Reference Main Generative Ai.Executablecodepart.Codeexecutionresult (`docs/reference/main/generative-ai.executablecodepart.codeexecutionresult.md`)
Home > @google/generative-ai > ExecutableCodePart > codeExecutionResult
ExecutableCodePart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Executablecodepart.Executablecode (`docs/reference/main/generative-ai.executablecodepart.executablecode.md`)
Home > @google/generative-ai > ExecutableCodePart > executableCode
ExecutableCodePart.executableCode property
Signature:
executableCode: ExecutableCode;Reference Main Generative Ai.Executablecodepart.Filedata (`docs/reference/main/generative-ai.executablecodepart.filedata.md`)
Home > @google/generative-ai > ExecutableCodePart > fileData
ExecutableCodePart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Executablecodepart.Functioncall (`docs/reference/main/generative-ai.executablecodepart.functioncall.md`)
Home > @google/generative-ai > ExecutableCodePart > functionCall
ExecutableCodePart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Executablecodepart.Functionresponse (`docs/reference/main/generative-ai.executablecodepart.functionresponse.md`)
Home > @google/generative-ai > ExecutableCodePart > functionResponse
ExecutableCodePart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Executablecodepart.Inlinedata (`docs/reference/main/generative-ai.executablecodepart.inlinedata.md`)
Home > @google/generative-ai > ExecutableCodePart > inlineData
ExecutableCodePart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Executablecodepart (`docs/reference/main/generative-ai.executablecodepart.md`)
Home > @google/generative-ai > ExecutableCodePart
ExecutableCodePart interface
Content part containing executable code generated by the model.
Signature:
export interface ExecutableCodePartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode | ExecutableCode | ||
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Main Generative Ai.Executablecodepart.Text (`docs/reference/main/generative-ai.executablecodepart.text.md`)
Home > @google/generative-ai > ExecutableCodePart > text
ExecutableCodePart.text property
Signature:
text?: never;Reference Main Generative Ai.Filedata.Fileuri (`docs/reference/main/generative-ai.filedata.fileuri.md`)
Home > @google/generative-ai > FileData > fileUri
FileData.fileUri property
Signature:
fileUri: string;Reference Main Generative Ai.Filedata (`docs/reference/main/generative-ai.filedata.md`)
Home > @google/generative-ai > FileData
FileData interface
Data pointing to a file uploaded with the Files API.
Signature:
export interface FileDataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| fileUri | string | ||
| mimeType | string |
Reference Main Generative Ai.Filedata.Mimetype (`docs/reference/main/generative-ai.filedata.mimetype.md`)
Home > @google/generative-ai > FileData > mimeType
FileData.mimeType property
Signature:
mimeType: string;Reference Main Generative Ai.Filedatapart.Codeexecutionresult (`docs/reference/main/generative-ai.filedatapart.codeexecutionresult.md`)
Home > @google/generative-ai > FileDataPart > codeExecutionResult
FileDataPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Filedatapart.Executablecode (`docs/reference/main/generative-ai.filedatapart.executablecode.md`)
Home > @google/generative-ai > FileDataPart > executableCode
FileDataPart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Filedatapart.Filedata (`docs/reference/main/generative-ai.filedatapart.filedata.md`)
Home > @google/generative-ai > FileDataPart > fileData
FileDataPart.fileData property
Signature:
fileData: FileData;Reference Main Generative Ai.Filedatapart.Functioncall (`docs/reference/main/generative-ai.filedatapart.functioncall.md`)
Home > @google/generative-ai > FileDataPart > functionCall
FileDataPart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Filedatapart.Functionresponse (`docs/reference/main/generative-ai.filedatapart.functionresponse.md`)
Home > @google/generative-ai > FileDataPart > functionResponse
FileDataPart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Filedatapart.Inlinedata (`docs/reference/main/generative-ai.filedatapart.inlinedata.md`)
Home > @google/generative-ai > FileDataPart > inlineData
FileDataPart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Filedatapart (`docs/reference/main/generative-ai.filedatapart.md`)
Home > @google/generative-ai > FileDataPart
FileDataPart interface
Content part interface if the part represents FileData.
Signature:
export interface FileDataPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData | FileData | ||
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Main Generative Ai.Filedatapart.Text (`docs/reference/main/generative-ai.filedatapart.text.md`)
Home > @google/generative-ai > FileDataPart > text
FileDataPart.text property
Signature:
text?: never;Reference Main Generative Ai.Finishreason (`docs/reference/main/generative-ai.finishreason.md`)
Home > @google/generative-ai > FinishReason
FinishReason enum
Reason that a candidate finished.
Signature:
export declare enum FinishReasonEnumeration Members
| Member | Value | Description |
|---|---|---|
| BLOCKLIST | "BLOCKLIST" |
|
| FINISH_REASON_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED" |
|
| LANGUAGE | "LANGUAGE" |
|
| MALFORMED_FUNCTION_CALL | "MALFORMED_FUNCTION_CALL" |
|
| MAX_TOKENS | "MAX_TOKENS" |
|
| OTHER | "OTHER" |
|
| PROHIBITED_CONTENT | "PROHIBITED_CONTENT" |
|
| RECITATION | "RECITATION" |
|
| SAFETY | "SAFETY" |
|
| SPII | "SPII" |
|
| STOP | "STOP" |
Reference Main Generative Ai.Functioncall.Args (`docs/reference/main/generative-ai.functioncall.args.md`)
Home > @google/generative-ai > FunctionCall > args
FunctionCall.args property
Signature:
args: object;Reference Main Generative Ai.Functioncall (`docs/reference/main/generative-ai.functioncall.md`)
Home > @google/generative-ai > FunctionCall
FunctionCall interface
A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing the parameters and their values.
Signature:
export interface FunctionCallProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| args | object | ||
| name | string |
Reference Main Generative Ai.Functioncall.Name (`docs/reference/main/generative-ai.functioncall.name.md`)
Home > @google/generative-ai > FunctionCall > name
FunctionCall.name property
Signature:
name: string;Reference Main Generative Ai.Functioncallingconfig.Allowedfunctionnames (`docs/reference/main/generative-ai.functioncallingconfig.allowedfunctionnames.md`)
Home > @google/generative-ai > FunctionCallingConfig > allowedFunctionNames
FunctionCallingConfig.allowedFunctionNames property
Signature:
allowedFunctionNames?: string[];Reference Main Generative Ai.Functioncallingconfig (`docs/reference/main/generative-ai.functioncallingconfig.md`)
Home > @google/generative-ai > FunctionCallingConfig
FunctionCallingConfig interface
Signature:
export interface FunctionCallingConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| allowedFunctionNames? | string[] | (Optional) | |
| mode? | FunctionCallingMode | (Optional) |
Reference Main Generative Ai.Functioncallingconfig.Mode (`docs/reference/main/generative-ai.functioncallingconfig.mode.md`)
Home > @google/generative-ai > FunctionCallingConfig > mode
FunctionCallingConfig.mode property
Signature:
mode?: FunctionCallingMode;Reference Main Generative Ai.Functioncallingmode (`docs/reference/main/generative-ai.functioncallingmode.md`)
Home > @google/generative-ai > FunctionCallingMode
FunctionCallingMode enum
Signature:
export declare enum FunctionCallingModeEnumeration Members
| Member | Value | Description |
|---|---|---|
| ANY | "ANY" |
|
| AUTO | "AUTO" |
|
| MODE_UNSPECIFIED | "MODE_UNSPECIFIED" |
|
| NONE | "NONE" |
Reference Main Generative Ai.Functioncallpart.Codeexecutionresult (`docs/reference/main/generative-ai.functioncallpart.codeexecutionresult.md`)
Home > @google/generative-ai > FunctionCallPart > codeExecutionResult
FunctionCallPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Functioncallpart.Executablecode (`docs/reference/main/generative-ai.functioncallpart.executablecode.md`)
Home > @google/generative-ai > FunctionCallPart > executableCode
FunctionCallPart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Functioncallpart.Filedata (`docs/reference/main/generative-ai.functioncallpart.filedata.md`)
Home > @google/generative-ai > FunctionCallPart > fileData
FunctionCallPart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Functioncallpart.Functioncall (`docs/reference/main/generative-ai.functioncallpart.functioncall.md`)
Home > @google/generative-ai > FunctionCallPart > functionCall
FunctionCallPart.functionCall property
Signature:
functionCall: FunctionCall;Reference Main Generative Ai.Functioncallpart.Functionresponse (`docs/reference/main/generative-ai.functioncallpart.functionresponse.md`)
Home > @google/generative-ai > FunctionCallPart > functionResponse
FunctionCallPart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Functioncallpart.Inlinedata (`docs/reference/main/generative-ai.functioncallpart.inlinedata.md`)
Home > @google/generative-ai > FunctionCallPart > inlineData
FunctionCallPart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Functioncallpart (`docs/reference/main/generative-ai.functioncallpart.md`)
Home > @google/generative-ai > FunctionCallPart
FunctionCallPart interface
Content part interface if the part represents a FunctionCall.
Signature:
export interface FunctionCallPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall | FunctionCall | ||
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Main Generative Ai.Functioncallpart.Text (`docs/reference/main/generative-ai.functioncallpart.text.md`)
Home > @google/generative-ai > FunctionCallPart > text
FunctionCallPart.text property
Signature:
text?: never;Reference Main Generative Ai.Functiondeclaration.Description (`docs/reference/main/generative-ai.functiondeclaration.description.md`)
Home > @google/generative-ai > FunctionDeclaration > description
FunctionDeclaration.description property
Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.
Signature:
description?: string;Reference Main Generative Ai.Functiondeclaration (`docs/reference/main/generative-ai.functiondeclaration.md`)
Home > @google/generative-ai > FunctionDeclaration
FunctionDeclaration interface
Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
Signature:
export declare interface FunctionDeclarationProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| description? | string | (Optional) Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. | |
| name | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | |
| parameters? | FunctionDeclarationSchema | (Optional) Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |
Reference Main Generative Ai.Functiondeclaration.Name (`docs/reference/main/generative-ai.functiondeclaration.name.md`)
Home > @google/generative-ai > FunctionDeclaration > name
FunctionDeclaration.name property
The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64.
Signature:
name: string;Reference Main Generative Ai.Functiondeclaration.Parameters (`docs/reference/main/generative-ai.functiondeclaration.parameters.md`)
Home > @google/generative-ai > FunctionDeclaration > parameters
FunctionDeclaration.parameters property
Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset.
Signature:
parameters?: FunctionDeclarationSchema;Example
with 1 required and 1 optional parameter: type: OBJECT properties:
param1:
type: STRING
param2:
type: INTEGER
required:
- param1Reference Main Generative Ai.Functiondeclarationschema.Description (`docs/reference/main/generative-ai.functiondeclarationschema.description.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > description
FunctionDeclarationSchema.description property
Optional. Description of the parameter.
Signature:
description?: string;Reference Main Generative Ai.Functiondeclarationschema (`docs/reference/main/generative-ai.functiondeclarationschema.md`)
Home > @google/generative-ai > FunctionDeclarationSchema
FunctionDeclarationSchema interface
Schema for parameters passed to FunctionDeclaration.parameters.
Signature:
export interface FunctionDeclarationSchemaProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| description? | string | (Optional) Optional. Description of the parameter. | |
| properties | { [k: string]: FunctionDeclarationSchemaProperty; } | The format of the parameter. | |
| required? | string[] | (Optional) Optional. Array of required parameters. | |
| type | SchemaType | The type of the parameter. |
Reference Main Generative Ai.Functiondeclarationschema.Properties (`docs/reference/main/generative-ai.functiondeclarationschema.properties.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > properties
FunctionDeclarationSchema.properties property
The format of the parameter.
Signature:
properties: {
[k: string]: FunctionDeclarationSchemaProperty;
};Reference Main Generative Ai.Functiondeclarationschema.Required (`docs/reference/main/generative-ai.functiondeclarationschema.required.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > required
FunctionDeclarationSchema.required property
Optional. Array of required parameters.
Signature:
required?: string[];Reference Main Generative Ai.Functiondeclarationschema.Type (`docs/reference/main/generative-ai.functiondeclarationschema.type.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > type
FunctionDeclarationSchema.type property
The type of the parameter.
Signature:
type: SchemaType;Reference Main Generative Ai.Functiondeclarationschemaproperty (`docs/reference/main/generative-ai.functiondeclarationschemaproperty.md`)
Home > @google/generative-ai > FunctionDeclarationSchemaProperty
FunctionDeclarationSchemaProperty type
Schema for top-level function declaration
Signature:
export type FunctionDeclarationSchemaProperty = Schema;References: Schema
Reference Main Generative Ai.Functiondeclarationstool.Functiondeclarations (`docs/reference/main/generative-ai.functiondeclarationstool.functiondeclarations.md`)
Home > @google/generative-ai > FunctionDeclarationsTool > functionDeclarations
FunctionDeclarationsTool.functionDeclarations property
Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall][content.part.functionCall] in the response. User should provide a [FunctionResponse][content.part.functionResponse] for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 64 function declarations can be provided.
Signature:
functionDeclarations?: FunctionDeclaration[];Reference Main Generative Ai.Functiondeclarationstool (`docs/reference/main/generative-ai.functiondeclarationstool.md`)
Home > @google/generative-ai > FunctionDeclarationsTool
FunctionDeclarationsTool interface
A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
Signature:
export declare interface FunctionDeclarationsToolProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| functionDeclarations? | FunctionDeclaration[] | (Optional) Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall][content.part.functionCall] in the response. User should provide a [FunctionResponse][content.part.functionResponse] for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 64 function declarations can be provided. |
Reference Main Generative Ai.Functionresponse (`docs/reference/main/generative-ai.functionresponse.md`)
Home > @google/generative-ai > FunctionResponse
FunctionResponse interface
The result output from a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall] made based on model prediction.
Signature:
export interface FunctionResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| name | string | ||
| response | object |
Reference Main Generative Ai.Functionresponse.Name (`docs/reference/main/generative-ai.functionresponse.name.md`)
Home > @google/generative-ai > FunctionResponse > name
FunctionResponse.name property
Signature:
name: string;Reference Main Generative Ai.Functionresponse.Response (`docs/reference/main/generative-ai.functionresponse.response.md`)
Home > @google/generative-ai > FunctionResponse > response
FunctionResponse.response property
Signature:
response: object;Reference Main Generative Ai.Functionresponsepart.Codeexecutionresult (`docs/reference/main/generative-ai.functionresponsepart.codeexecutionresult.md`)
Home > @google/generative-ai > FunctionResponsePart > codeExecutionResult
FunctionResponsePart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Functionresponsepart.Executablecode (`docs/reference/main/generative-ai.functionresponsepart.executablecode.md`)
Home > @google/generative-ai > FunctionResponsePart > executableCode
FunctionResponsePart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Functionresponsepart.Filedata (`docs/reference/main/generative-ai.functionresponsepart.filedata.md`)
Home > @google/generative-ai > FunctionResponsePart > fileData
FunctionResponsePart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Functionresponsepart.Functioncall (`docs/reference/main/generative-ai.functionresponsepart.functioncall.md`)
Home > @google/generative-ai > FunctionResponsePart > functionCall
FunctionResponsePart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Functionresponsepart.Functionresponse (`docs/reference/main/generative-ai.functionresponsepart.functionresponse.md`)
Home > @google/generative-ai > FunctionResponsePart > functionResponse
FunctionResponsePart.functionResponse property
Signature:
functionResponse: FunctionResponse;Reference Main Generative Ai.Functionresponsepart.Inlinedata (`docs/reference/main/generative-ai.functionresponsepart.inlinedata.md`)
Home > @google/generative-ai > FunctionResponsePart > inlineData
FunctionResponsePart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Functionresponsepart (`docs/reference/main/generative-ai.functionresponsepart.md`)
Home > @google/generative-ai > FunctionResponsePart
FunctionResponsePart interface
Content part interface if the part represents FunctionResponse.
Signature:
export interface FunctionResponsePartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse | FunctionResponse | ||
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Main Generative Ai.Functionresponsepart.Text (`docs/reference/main/generative-ai.functionresponsepart.text.md`)
Home > @google/generative-ai > FunctionResponsePart > text
FunctionResponsePart.text property
Signature:
text?: never;Reference Main Generative Ai.Generatecontentcandidate.Avglogprobs (`docs/reference/main/generative-ai.generatecontentcandidate.avglogprobs.md`)
Home > @google/generative-ai > GenerateContentCandidate > avgLogprobs
GenerateContentCandidate.avgLogprobs property
Average log probability score of the candidate.
Signature:
avgLogprobs?: number;Reference Main Generative Ai.Generatecontentcandidate.Citationmetadata (`docs/reference/main/generative-ai.generatecontentcandidate.citationmetadata.md`)
Home > @google/generative-ai > GenerateContentCandidate > citationMetadata
GenerateContentCandidate.citationMetadata property
Signature:
citationMetadata?: CitationMetadata;Reference Main Generative Ai.Generatecontentcandidate.Content (`docs/reference/main/generative-ai.generatecontentcandidate.content.md`)
Home > @google/generative-ai > GenerateContentCandidate > content
GenerateContentCandidate.content property
Signature:
content: Content;Reference Main Generative Ai.Generatecontentcandidate.Finishmessage (`docs/reference/main/generative-ai.generatecontentcandidate.finishmessage.md`)
Home > @google/generative-ai > GenerateContentCandidate > finishMessage
GenerateContentCandidate.finishMessage property
Signature:
finishMessage?: string;Reference Main Generative Ai.Generatecontentcandidate.Finishreason (`docs/reference/main/generative-ai.generatecontentcandidate.finishreason.md`)
Home > @google/generative-ai > GenerateContentCandidate > finishReason
GenerateContentCandidate.finishReason property
Signature:
finishReason?: FinishReason;Reference Main Generative Ai.Generatecontentcandidate.Groundingmetadata (`docs/reference/main/generative-ai.generatecontentcandidate.groundingmetadata.md`)
Home > @google/generative-ai > GenerateContentCandidate > groundingMetadata
GenerateContentCandidate.groundingMetadata property
Search grounding metadata.
Signature:
groundingMetadata?: GroundingMetadata;Reference Main Generative Ai.Generatecontentcandidate.Logprobsresult (`docs/reference/main/generative-ai.generatecontentcandidate.logprobsresult.md`)
Home > @google/generative-ai > GenerateContentCandidate > logprobsResult
GenerateContentCandidate.logprobsResult property
Log-likelihood scores for the response tokens and top tokens.
Signature:
logprobsResult?: LogprobsResult;Reference Main Generative Ai.Generatecontentcandidate (`docs/reference/main/generative-ai.generatecontentcandidate.md`)
Home > @google/generative-ai > GenerateContentCandidate
GenerateContentCandidate interface
A candidate returned as part of a GenerateContentResponse.
Signature:
export interface GenerateContentCandidateProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| avgLogprobs? | number | (Optional) Average log probability score of the candidate. | |
| citationMetadata? | CitationMetadata | (Optional) | |
| content | Content | ||
| finishMessage? | string | (Optional) | |
| finishReason? | FinishReason | (Optional) | |
| groundingMetadata? | GroundingMetadata | (Optional) Search grounding metadata. | |
| index | number | ||
| logprobsResult? | LogprobsResult | (Optional) Log-likelihood scores for the response tokens and top tokens. | |
| safetyRatings? | SafetyRating[] | (Optional) |
Reference Main Generative Ai.Generatecontentcandidate.Safetyratings (`docs/reference/main/generative-ai.generatecontentcandidate.safetyratings.md`)
Home > @google/generative-ai > GenerateContentCandidate > safetyRatings
GenerateContentCandidate.safetyRatings property
Signature:
safetyRatings?: SafetyRating[];Reference Main Generative Ai.Generatecontentrequest.Cachedcontent (`docs/reference/main/generative-ai.generatecontentrequest.cachedcontent.md`)
Home > @google/generative-ai > GenerateContentRequest > cachedContent
GenerateContentRequest.cachedContent property
This is the name of a CachedContent and not the cache object itself.
Signature:
cachedContent?: string;Reference Main Generative Ai.Generatecontentrequest.Contents (`docs/reference/main/generative-ai.generatecontentrequest.contents.md`)
Home > @google/generative-ai > GenerateContentRequest > contents
GenerateContentRequest.contents property
Signature:
contents: Content[];Reference Main Generative Ai.Generatecontentrequest (`docs/reference/main/generative-ai.generatecontentrequest.md`)
Home > @google/generative-ai > GenerateContentRequest
GenerateContentRequest interface
Request sent to generateContent endpoint.
Signature:
export interface GenerateContentRequest extends BaseParamsExtends: BaseParams
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContent? | string | (Optional) This is the name of a CachedContent and not the cache object itself. |
|
| contents | Content[] | ||
| systemInstruction? | string | Part | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Reference Main Generative Ai.Generatecontentrequest.Systeminstruction (`docs/reference/main/generative-ai.generatecontentrequest.systeminstruction.md`)
Home > @google/generative-ai > GenerateContentRequest > systemInstruction
GenerateContentRequest.systemInstruction property
Signature:
systemInstruction?: string | Part | Content;Reference Main Generative Ai.Generatecontentrequest.Toolconfig (`docs/reference/main/generative-ai.generatecontentrequest.toolconfig.md`)
Home > @google/generative-ai > GenerateContentRequest > toolConfig
GenerateContentRequest.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Main Generative Ai.Generatecontentrequest.Tools (`docs/reference/main/generative-ai.generatecontentrequest.tools.md`)
Home > @google/generative-ai > GenerateContentRequest > tools
GenerateContentRequest.tools property
Signature:
tools?: Tool[];Reference Main Generative Ai.Generatecontentresponse.Candidates (`docs/reference/main/generative-ai.generatecontentresponse.candidates.md`)
Home > @google/generative-ai > GenerateContentResponse > candidates
GenerateContentResponse.candidates property
Candidate responses from the model.
Signature:
candidates?: GenerateContentCandidate[];Reference Main Generative Ai.Generatecontentresponse (`docs/reference/main/generative-ai.generatecontentresponse.md`)
Home > @google/generative-ai > GenerateContentResponse
GenerateContentResponse interface
Individual response from GenerativeModel.generateContent() and GenerativeModel.generateContentStream(). generateContentStream() will return one in each chunk until the stream is done.
Signature:
export interface GenerateContentResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| candidates? | GenerateContentCandidate[] | (Optional) Candidate responses from the model. | |
| promptFeedback? | PromptFeedback | (Optional) The prompt's feedback related to the content filters. | |
| usageMetadata? | UsageMetadata | (Optional) Metadata on the generation request's token usage. |
Reference Main Generative Ai.Generatecontentresponse.Promptfeedback (`docs/reference/main/generative-ai.generatecontentresponse.promptfeedback.md`)
Home > @google/generative-ai > GenerateContentResponse > promptFeedback
GenerateContentResponse.promptFeedback property
The prompt's feedback related to the content filters.
Signature:
promptFeedback?: PromptFeedback;Reference Main Generative Ai.Generatecontentresponse.Usagemetadata (`docs/reference/main/generative-ai.generatecontentresponse.usagemetadata.md`)
Home > @google/generative-ai > GenerateContentResponse > usageMetadata
GenerateContentResponse.usageMetadata property
Metadata on the generation request's token usage.
Signature:
usageMetadata?: UsageMetadata;Reference Main Generative Ai.Generatecontentresult (`docs/reference/main/generative-ai.generatecontentresult.md`)
Home > @google/generative-ai > GenerateContentResult
GenerateContentResult interface
Result object returned from generateContent() call.
Signature:
export interface GenerateContentResultProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| response | EnhancedGenerateContentResponse |
Reference Main Generative Ai.Generatecontentresult.Response (`docs/reference/main/generative-ai.generatecontentresult.response.md`)
Home > @google/generative-ai > GenerateContentResult > response
GenerateContentResult.response property
Signature:
response: EnhancedGenerateContentResponse;Reference Main Generative Ai.Generatecontentstreamresult (`docs/reference/main/generative-ai.generatecontentstreamresult.md`)
Home > @google/generative-ai > GenerateContentStreamResult
GenerateContentStreamResult interface
Result object returned from generateContentStream() call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done.
Signature:
export interface GenerateContentStreamResultProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| response | Promise<EnhancedGenerateContentResponse> | ||
| stream | AsyncGenerator<EnhancedGenerateContentResponse> |
Reference Main Generative Ai.Generatecontentstreamresult.Response (`docs/reference/main/generative-ai.generatecontentstreamresult.response.md`)
Home > @google/generative-ai > GenerateContentStreamResult > response
GenerateContentStreamResult.response property
Signature:
response: Promise<EnhancedGenerateContentResponse>;Reference Main Generative Ai.Generatecontentstreamresult.Stream (`docs/reference/main/generative-ai.generatecontentstreamresult.stream.md`)
Home > @google/generative-ai > GenerateContentStreamResult > stream
GenerateContentStreamResult.stream property
Signature:
stream: AsyncGenerator<EnhancedGenerateContentResponse>;Reference Main Generative Ai.Generationconfig.Candidatecount (`docs/reference/main/generative-ai.generationconfig.candidatecount.md`)
Home > @google/generative-ai > GenerationConfig > candidateCount
GenerationConfig.candidateCount property
Signature:
candidateCount?: number;Reference Main Generative Ai.Generationconfig.Frequencypenalty (`docs/reference/main/generative-ai.generationconfig.frequencypenalty.md`)
Home > @google/generative-ai > GenerationConfig > frequencyPenalty
GenerationConfig.frequencyPenalty property
Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far.
Signature:
frequencyPenalty?: number;Reference Main Generative Ai.Generationconfig.Logprobs (`docs/reference/main/generative-ai.generationconfig.logprobs.md`)
Home > @google/generative-ai > GenerationConfig > logprobs
GenerationConfig.logprobs property
Valid if responseLogProbs is set to True. This will set the number of top logprobs to return at each decoding step in the logprobsResult.
Signature:
logprobs?: number;Reference Main Generative Ai.Generationconfig.Maxoutputtokens (`docs/reference/main/generative-ai.generationconfig.maxoutputtokens.md`)
Home > @google/generative-ai > GenerationConfig > maxOutputTokens
GenerationConfig.maxOutputTokens property
Signature:
maxOutputTokens?: number;Reference Main Generative Ai.Generationconfig (`docs/reference/main/generative-ai.generationconfig.md`)
Home > @google/generative-ai > GenerationConfig
GenerationConfig interface
Config options for content-related requests
Signature:
export interface GenerationConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| candidateCount? | number | (Optional) | |
| frequencyPenalty? | number | (Optional) Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the respponse so far. | |
| logprobs? | number | (Optional) Valid if responseLogProbs is set to True. This will set the number of top logprobs to return at each decoding step in the logprobsResult. | |
| maxOutputTokens? | number | (Optional) | |
| presencePenalty? | number | (Optional) Presence penalty applied to the next token's logprobs if the token has already been seen in the response. | |
| responseLogprobs? | boolean | (Optional) If True, export the logprobs results in response. | |
| responseMimeType? | string | (Optional) Output response mimetype of the generated candidate text. Supported mimetype: text/plain: (default) Text output. application/json: JSON response in the candidates. |
|
| responseSchema? | ResponseSchema | (Optional) Output response schema of the generated candidate text. Note: This only applies when the specified responseMIMEType supports a schema; currently this is limited to application/json. |
|
| stopSequences? | string[] | (Optional) | |
| temperature? | number | (Optional) | |
| topK? | number | (Optional) | |
| topP? | number | (Optional) |
Reference Main Generative Ai.Generationconfig.Presencepenalty (`docs/reference/main/generative-ai.generationconfig.presencepenalty.md`)
Home > @google/generative-ai > GenerationConfig > presencePenalty
GenerationConfig.presencePenalty property
Presence penalty applied to the next token's logprobs if the token has already been seen in the response.
Signature:
presencePenalty?: number;Reference Main Generative Ai.Generationconfig.Responselogprobs (`docs/reference/main/generative-ai.generationconfig.responselogprobs.md`)
Home > @google/generative-ai > GenerationConfig > responseLogprobs
GenerationConfig.responseLogprobs property
If True, export the logprobs results in response.
Signature:
responseLogprobs?: boolean;Reference Main Generative Ai.Generationconfig.Responsemimetype (`docs/reference/main/generative-ai.generationconfig.responsemimetype.md`)
Home > @google/generative-ai > GenerationConfig > responseMimeType
GenerationConfig.responseMimeType property
Output response mimetype of the generated candidate text. Supported mimetype: text/plain: (default) Text output. application/json: JSON response in the candidates.
Signature:
responseMimeType?: string;Reference Main Generative Ai.Generationconfig.Responseschema (`docs/reference/main/generative-ai.generationconfig.responseschema.md`)
Home > @google/generative-ai > GenerationConfig > responseSchema
GenerationConfig.responseSchema property
Output response schema of the generated candidate text. Note: This only applies when the specified responseMIMEType supports a schema; currently this is limited to application/json.
Signature:
responseSchema?: ResponseSchema;Reference Main Generative Ai.Generationconfig.Stopsequences (`docs/reference/main/generative-ai.generationconfig.stopsequences.md`)
Home > @google/generative-ai > GenerationConfig > stopSequences
GenerationConfig.stopSequences property
Signature:
stopSequences?: string[];Reference Main Generative Ai.Generationconfig.Temperature (`docs/reference/main/generative-ai.generationconfig.temperature.md`)
Home > @google/generative-ai > GenerationConfig > temperature
GenerationConfig.temperature property
Signature:
temperature?: number;Reference Main Generative Ai.Generationconfig.Topk (`docs/reference/main/generative-ai.generationconfig.topk.md`)
Home > @google/generative-ai > GenerationConfig > topK
GenerationConfig.topK property
Signature:
topK?: number;Reference Main Generative Ai.Generationconfig.Topp (`docs/reference/main/generative-ai.generationconfig.topp.md`)
Home > @google/generative-ai > GenerationConfig > topP
GenerationConfig.topP property
Signature:
topP?: number;Reference Main Generative Ai.Generativecontentblob.Data (`docs/reference/main/generative-ai.generativecontentblob.data.md`)
Home > @google/generative-ai > GenerativeContentBlob > data
GenerativeContentBlob.data property
Image as a base64 string.
Signature:
data: string;Reference Main Generative Ai.Generativecontentblob (`docs/reference/main/generative-ai.generativecontentblob.md`)
Home > @google/generative-ai > GenerativeContentBlob
GenerativeContentBlob interface
Interface for sending an image.
Signature:
export interface GenerativeContentBlobProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| data | string | Image as a base64 string. | |
| mimeType | string |
Reference Main Generative Ai.Generativecontentblob.Mimetype (`docs/reference/main/generative-ai.generativecontentblob.mimetype.md`)
Home > @google/generative-ai > GenerativeContentBlob > mimeType
GenerativeContentBlob.mimeType property
Signature:
mimeType: string;Reference Main Generative Ai.Generativemodel. Constructor (`docs/reference/main/generative-ai.generativemodel._constructor_.md`)
Home > @google/generative-ai > GenerativeModel > (constructor)
GenerativeModel.(constructor)
Constructs a new instance of the GenerativeModel class
Signature:
constructor(apiKey: string, modelParams: ModelParams, _requestOptions?: RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string | |
| modelParams | ModelParams | |
| _requestOptions | RequestOptions | (Optional) |
Reference Main Generative Ai.Generativemodel.Apikey (`docs/reference/main/generative-ai.generativemodel.apikey.md`)
Home > @google/generative-ai > GenerativeModel > apiKey
GenerativeModel.apiKey property
Signature:
apiKey: string;Reference Main Generative Ai.Generativemodel.Batchembedcontents (`docs/reference/main/generative-ai.generativemodel.batchembedcontents.md`)
Home > @google/generative-ai > GenerativeModel > batchEmbedContents
GenerativeModel.batchEmbedContents() method
Embeds an array of EmbedContentRequests.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
batchEmbedContents(batchEmbedContentRequest: BatchEmbedContentsRequest, requestOptions?: SingleRequestOptions): Promise<BatchEmbedContentsResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| batchEmbedContentRequest | BatchEmbedContentsRequest | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<BatchEmbedContentsResponse>
Reference Main Generative Ai.Generativemodel.Cachedcontent (`docs/reference/main/generative-ai.generativemodel.cachedcontent.md`)
Home > @google/generative-ai > GenerativeModel > cachedContent
GenerativeModel.cachedContent property
Signature:
cachedContent: CachedContent;Reference Main Generative Ai.Generativemodel.Counttokens (`docs/reference/main/generative-ai.generativemodel.counttokens.md`)
Home > @google/generative-ai > GenerativeModel > countTokens
GenerativeModel.countTokens() method
Counts the tokens in the provided request.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
countTokens(request: CountTokensRequest | string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<CountTokensResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | CountTokensRequest | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<CountTokensResponse>
Reference Main Generative Ai.Generativemodel.Embedcontent (`docs/reference/main/generative-ai.generativemodel.embedcontent.md`)
Home > @google/generative-ai > GenerativeModel > embedContent
GenerativeModel.embedContent() method
Embeds the provided content.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
embedContent(request: EmbedContentRequest | string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<EmbedContentResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | EmbedContentRequest | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<EmbedContentResponse>
Reference Main Generative Ai.Generativemodel.Generatecontent (`docs/reference/main/generative-ai.generativemodel.generatecontent.md`)
Home > @google/generative-ai > GenerativeModel > generateContent
GenerativeModel.generateContent() method
Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
generateContent(request: GenerateContentRequest | string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<GenerateContentResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<GenerateContentResult>
Reference Main Generative Ai.Generativemodel.Generatecontentstream (`docs/reference/main/generative-ai.generativemodel.generatecontentstream.md`)
Home > @google/generative-ai > GenerativeModel > generateContentStream
GenerativeModel.generateContentStream() method
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.
Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel().
Signature:
generateContentStream(request: GenerateContentRequest | string | Array<string | Part>, requestOptions?: SingleRequestOptions): Promise<GenerateContentStreamResult>;Parameters
| Parameter | Type | Description |
|---|---|---|
| request | GenerateContentRequest | string | Array<string | Part> | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<GenerateContentStreamResult>
Reference Main Generative Ai.Generativemodel.Generationconfig (`docs/reference/main/generative-ai.generativemodel.generationconfig.md`)
Home > @google/generative-ai > GenerativeModel > generationConfig
GenerativeModel.generationConfig property
Signature:
generationConfig: GenerationConfig;Reference Main Generative Ai.Generativemodel (`docs/reference/main/generative-ai.generativemodel.md`)
Home > @google/generative-ai > GenerativeModel
GenerativeModel class
Class for generative model APIs.
Signature:
export declare class GenerativeModelConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, modelParams, _requestOptions) | Constructs a new instance of the GenerativeModel class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiKey | string | ||
| cachedContent | CachedContent | ||
| generationConfig | GenerationConfig | ||
| model | string | ||
| safetySettings | SafetySetting[] | ||
| systemInstruction? | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Methods
| Method | Modifiers | Description |
|---|---|---|
| batchEmbedContents(batchEmbedContentRequest, requestOptions) | Embeds an array of EmbedContentRequests.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| countTokens(request, requestOptions) | Counts the tokens in the provided request.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| embedContent(request, requestOptions) | Embeds the provided content.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| generateContent(request, requestOptions) | Makes a single non-streaming call to the model and returns an object containing a single GenerateContentResponse.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| generateContentStream(request, requestOptions) | 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.Fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided to GoogleGenerativeAI.getGenerativeModel(). | |
| startChat(startChatParams) | Gets a new ChatSession instance which can be used for multi-turn chats. |
Reference Main Generative Ai.Generativemodel.Model (`docs/reference/main/generative-ai.generativemodel.model.md`)
Home > @google/generative-ai > GenerativeModel > model
GenerativeModel.model property
Signature:
model: string;Reference Main Generative Ai.Generativemodel.Safetysettings (`docs/reference/main/generative-ai.generativemodel.safetysettings.md`)
Home > @google/generative-ai > GenerativeModel > safetySettings
GenerativeModel.safetySettings property
Signature:
safetySettings: SafetySetting[];Reference Main Generative Ai.Generativemodel.Startchat (`docs/reference/main/generative-ai.generativemodel.startchat.md`)
Home > @google/generative-ai > GenerativeModel > startChat
GenerativeModel.startChat() method
Gets a new ChatSession instance which can be used for multi-turn chats.
Signature:
startChat(startChatParams?: StartChatParams): ChatSession;Parameters
| Parameter | Type | Description |
|---|---|---|
| startChatParams | StartChatParams | (Optional) |
Returns:
Reference Main Generative Ai.Generativemodel.Systeminstruction (`docs/reference/main/generative-ai.generativemodel.systeminstruction.md`)
Home > @google/generative-ai > GenerativeModel > systemInstruction
GenerativeModel.systemInstruction property
Signature:
systemInstruction?: Content;Reference Main Generative Ai.Generativemodel.Toolconfig (`docs/reference/main/generative-ai.generativemodel.toolconfig.md`)
Home > @google/generative-ai > GenerativeModel > toolConfig
GenerativeModel.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Main Generative Ai.Generativemodel.Tools (`docs/reference/main/generative-ai.generativemodel.tools.md`)
Home > @google/generative-ai > GenerativeModel > tools
GenerativeModel.tools property
Signature:
tools?: Tool[];Reference Main Generative Ai.Googlegenerativeai. Constructor (`docs/reference/main/generative-ai.googlegenerativeai._constructor_.md`)
Home > @google/generative-ai > GoogleGenerativeAI > (constructor)
GoogleGenerativeAI.(constructor)
Constructs a new instance of the GoogleGenerativeAI class
Signature:
constructor(apiKey: string);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string |
Reference Main Generative Ai.Googlegenerativeai.Apikey (`docs/reference/main/generative-ai.googlegenerativeai.apikey.md`)
Home > @google/generative-ai > GoogleGenerativeAI > apiKey
GoogleGenerativeAI.apiKey property
Signature:
apiKey: string;Reference Main Generative Ai.Googlegenerativeai.Getgenerativemodel (`docs/reference/main/generative-ai.googlegenerativeai.getgenerativemodel.md`)
Home > @google/generative-ai > GoogleGenerativeAI > getGenerativeModel
GoogleGenerativeAI.getGenerativeModel() method
Gets a GenerativeModel instance for the provided model name.
Signature:
getGenerativeModel(modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;Parameters
| Parameter | Type | Description |
|---|---|---|
| modelParams | ModelParams | |
| requestOptions | RequestOptions | (Optional) |
Returns:
Reference Main Generative Ai.Googlegenerativeai.Getgenerativemodelfromcachedcontent (`docs/reference/main/generative-ai.googlegenerativeai.getgenerativemodelfromcachedcontent.md`)
Home > @google/generative-ai > GoogleGenerativeAI > getGenerativeModelFromCachedContent
GoogleGenerativeAI.getGenerativeModelFromCachedContent() method
Creates a GenerativeModel instance from provided content cache.
Signature:
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel;Parameters
| Parameter | Type | Description |
|---|---|---|
| cachedContent | CachedContent | |
| modelParams | Partial<ModelParams> | (Optional) |
| requestOptions | RequestOptions | (Optional) |
Returns:
Reference Main Generative Ai.Googlegenerativeai (`docs/reference/main/generative-ai.googlegenerativeai.md`)
Home > @google/generative-ai > GoogleGenerativeAI
GoogleGenerativeAI class
Top-level class for this SDK
Signature:
export declare class GoogleGenerativeAIConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey) | Constructs a new instance of the GoogleGenerativeAI class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiKey | string |
Methods
| Method | Modifiers | Description |
|---|---|---|
| getGenerativeModel(modelParams, requestOptions) | Gets a GenerativeModel instance for the provided model name. | |
| getGenerativeModelFromCachedContent(cachedContent, modelParams, requestOptions) | Creates a GenerativeModel instance from provided content cache. |
Reference Main Generative Ai.Googlegenerativeaiaborterror (`docs/reference/main/generative-ai.googlegenerativeaiaborterror.md`)
Home > @google/generative-ai > GoogleGenerativeAIAbortError
GoogleGenerativeAIAbortError class
Error thrown when a request is aborted, either due to a timeout or intentional cancellation by the user.
Signature:
export declare class GoogleGenerativeAIAbortError extends GoogleGenerativeAIErrorExtends: GoogleGenerativeAIError
Reference Main Generative Ai.Googlegenerativeaierror. Constructor (`docs/reference/main/generative-ai.googlegenerativeaierror._constructor_.md`)
Home > @google/generative-ai > GoogleGenerativeAIError > (constructor)
GoogleGenerativeAIError.(constructor)
Constructs a new instance of the GoogleGenerativeAIError class
Signature:
constructor(message: string);Parameters
| Parameter | Type | Description |
|---|---|---|
| message | string |
Reference Main Generative Ai.Googlegenerativeaierror (`docs/reference/main/generative-ai.googlegenerativeaierror.md`)
Home > @google/generative-ai > GoogleGenerativeAIError
GoogleGenerativeAIError class
Basic error type for this SDK.
Signature:
export declare class GoogleGenerativeAIError extends ErrorExtends: Error
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(message) | Constructs a new instance of the GoogleGenerativeAIError class |
Reference Main Generative Ai.Googlegenerativeaifetcherror. Constructor (`docs/reference/main/generative-ai.googlegenerativeaifetcherror._constructor_.md`)
Home > @google/generative-ai > GoogleGenerativeAIFetchError > (constructor)
GoogleGenerativeAIFetchError.(constructor)
Constructs a new instance of the GoogleGenerativeAIFetchError class
Signature:
constructor(message: string, status?: number, statusText?: string, errorDetails?: ErrorDetails[]);Parameters
| Parameter | Type | Description |
|---|---|---|
| message | string | |
| status | number | (Optional) |
| statusText | string | (Optional) |
| errorDetails | ErrorDetails[] | (Optional) |
Reference Main Generative Ai.Googlegenerativeaifetcherror.Errordetails (`docs/reference/main/generative-ai.googlegenerativeaifetcherror.errordetails.md`)
Home > @google/generative-ai > GoogleGenerativeAIFetchError > errorDetails
GoogleGenerativeAIFetchError.errorDetails property
Signature:
errorDetails?: ErrorDetails[];Reference Main Generative Ai.Googlegenerativeaifetcherror (`docs/reference/main/generative-ai.googlegenerativeaifetcherror.md`)
Home > @google/generative-ai > GoogleGenerativeAIFetchError
GoogleGenerativeAIFetchError class
Error class covering HTTP errors when calling the server. Includes HTTP status, statusText, and optional details, if provided in the server response.
Signature:
export declare class GoogleGenerativeAIFetchError extends GoogleGenerativeAIErrorExtends: GoogleGenerativeAIError
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(message, status, statusText, errorDetails) | Constructs a new instance of the GoogleGenerativeAIFetchError class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| errorDetails? | ErrorDetails[] | (Optional) | |
| status? | number | (Optional) | |
| statusText? | string | (Optional) |
Reference Main Generative Ai.Googlegenerativeaifetcherror.Status (`docs/reference/main/generative-ai.googlegenerativeaifetcherror.status.md`)
Home > @google/generative-ai > GoogleGenerativeAIFetchError > status
GoogleGenerativeAIFetchError.status property
Signature:
status?: number;Reference Main Generative Ai.Googlegenerativeaifetcherror.Statustext (`docs/reference/main/generative-ai.googlegenerativeaifetcherror.statustext.md`)
Home > @google/generative-ai > GoogleGenerativeAIFetchError > statusText
GoogleGenerativeAIFetchError.statusText property
Signature:
statusText?: string;Reference Main Generative Ai.Googlegenerativeairequestinputerror (`docs/reference/main/generative-ai.googlegenerativeairequestinputerror.md`)
Home > @google/generative-ai > GoogleGenerativeAIRequestInputError
GoogleGenerativeAIRequestInputError class
Errors in the contents of a request originating from user input.
Signature:
export declare class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIErrorExtends: GoogleGenerativeAIError
Reference Main Generative Ai.Googlegenerativeairesponseerror. Constructor (`docs/reference/main/generative-ai.googlegenerativeairesponseerror._constructor_.md`)
Home > @google/generative-ai > GoogleGenerativeAIResponseError > (constructor)
GoogleGenerativeAIResponseError.(constructor)
Constructs a new instance of the GoogleGenerativeAIResponseError class
Signature:
constructor(message: string, response?: T);Parameters
| Parameter | Type | Description |
|---|---|---|
| message | string | |
| response | T | (Optional) |
Reference Main Generative Ai.Googlegenerativeairesponseerror (`docs/reference/main/generative-ai.googlegenerativeairesponseerror.md`)
Home > @google/generative-ai > GoogleGenerativeAIResponseError
GoogleGenerativeAIResponseError class
Errors in the contents of a response from the model. This includes parsing errors, or responses including a safety block reason.
Signature:
export declare class GoogleGenerativeAIResponseError<T> extends GoogleGenerativeAIErrorExtends: GoogleGenerativeAIError
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(message, response) | Constructs a new instance of the GoogleGenerativeAIResponseError class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| response? | T | (Optional) |
Reference Main Generative Ai.Googlegenerativeairesponseerror.Response (`docs/reference/main/generative-ai.googlegenerativeairesponseerror.response.md`)
Home > @google/generative-ai > GoogleGenerativeAIResponseError > response
GoogleGenerativeAIResponseError.response property
Signature:
response?: T;Reference Main Generative Ai.Googlesearchretrieval.Dynamicretrievalconfig (`docs/reference/main/generative-ai.googlesearchretrieval.dynamicretrievalconfig.md`)
Home > @google/generative-ai > GoogleSearchRetrieval > dynamicRetrievalConfig
GoogleSearchRetrieval.dynamicRetrievalConfig property
Specifies the dynamic retrieval configuration for the given source.
Signature:
dynamicRetrievalConfig?: DynamicRetrievalConfig;Reference Main Generative Ai.Googlesearchretrieval (`docs/reference/main/generative-ai.googlesearchretrieval.md`)
Home > @google/generative-ai > GoogleSearchRetrieval
GoogleSearchRetrieval interface
Retrieval tool that is powered by Google search.
Signature:
export declare interface GoogleSearchRetrievalProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| dynamicRetrievalConfig? | DynamicRetrievalConfig | (Optional) Specifies the dynamic retrieval configuration for the given source. |
Reference Main Generative Ai.Googlesearchretrievaltool.Googlesearchretrieval (`docs/reference/main/generative-ai.googlesearchretrievaltool.googlesearchretrieval.md`)
Home > @google/generative-ai > GoogleSearchRetrievalTool > googleSearchRetrieval
GoogleSearchRetrievalTool.googleSearchRetrieval property
Google search retrieval tool config.
Signature:
googleSearchRetrieval?: GoogleSearchRetrieval;Reference Main Generative Ai.Googlesearchretrievaltool (`docs/reference/main/generative-ai.googlesearchretrievaltool.md`)
Home > @google/generative-ai > GoogleSearchRetrievalTool
GoogleSearchRetrievalTool interface
Retrieval tool that is powered by Google search.
Signature:
export declare interface GoogleSearchRetrievalToolProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| googleSearchRetrieval? | GoogleSearchRetrieval | (Optional) Google search retrieval tool config. |
Reference Main Generative Ai.Groundingchunk (`docs/reference/main/generative-ai.groundingchunk.md`)
Home > @google/generative-ai > GroundingChunk
GroundingChunk interface
Grounding chunk.
Signature:
export declare interface GroundingChunkProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| web? | GroundingChunkWeb | (Optional) Chunk from the web. |
Reference Main Generative Ai.Groundingchunk.Web (`docs/reference/main/generative-ai.groundingchunk.web.md`)
Home > @google/generative-ai > GroundingChunk > web
GroundingChunk.web property
Chunk from the web.
Signature:
web?: GroundingChunkWeb;Reference Main Generative Ai.Groundingchunkweb (`docs/reference/main/generative-ai.groundingchunkweb.md`)
Home > @google/generative-ai > GroundingChunkWeb
GroundingChunkWeb interface
Chunk from the web.
Signature:
export declare interface GroundingChunkWebProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| title? | string | (Optional) Title of the chunk. | |
| uri? | string | (Optional) URI reference of the chunk. |
Reference Main Generative Ai.Groundingchunkweb.Title (`docs/reference/main/generative-ai.groundingchunkweb.title.md`)
Home > @google/generative-ai > GroundingChunkWeb > title
GroundingChunkWeb.title property
Title of the chunk.
Signature:
title?: string;Reference Main Generative Ai.Groundingchunkweb.Uri (`docs/reference/main/generative-ai.groundingchunkweb.uri.md`)
Home > @google/generative-ai > GroundingChunkWeb > uri
GroundingChunkWeb.uri property
URI reference of the chunk.
Signature:
uri?: string;Reference Main Generative Ai.Groundingmetadata.Groundingchunks (`docs/reference/main/generative-ai.groundingmetadata.groundingchunks.md`)
Home > @google/generative-ai > GroundingMetadata > groundingChunks
GroundingMetadata.groundingChunks property
List of supporting references retrieved from specified grounding source.
Signature:
groundingChunks?: GroundingChunk[];Reference Main Generative Ai.Groundingmetadata.Groundingsupports (`docs/reference/main/generative-ai.groundingmetadata.groundingsupports.md`)
Home > @google/generative-ai > GroundingMetadata > groundingSupports
GroundingMetadata.groundingSupports property
List of grounding support.
Signature:
groundingSupports?: GroundingSupport[];Reference Main Generative Ai.Groundingmetadata (`docs/reference/main/generative-ai.groundingmetadata.md`)
Home > @google/generative-ai > GroundingMetadata
GroundingMetadata interface
Metadata returned to client when grounding is enabled.
Signature:
export declare interface GroundingMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| groundingChunks? | GroundingChunk[] | (Optional) List of supporting references retrieved from specified grounding source. | |
| groundingSupports? | GroundingSupport[] | (Optional) List of grounding support. | |
| retrievalMetadata? | RetrievalMetadata | (Optional) Metadata related to retrieval in the grounding flow. | |
| searchEntryPoint? | SearchEntryPoint | (Optional) Google search entry for the following-up web searches. | |
| webSearchQueries | string[] | * Web search queries for the following-up web search. |
Reference Main Generative Ai.Groundingmetadata.Retrievalmetadata (`docs/reference/main/generative-ai.groundingmetadata.retrievalmetadata.md`)
Home > @google/generative-ai > GroundingMetadata > retrievalMetadata
GroundingMetadata.retrievalMetadata property
Metadata related to retrieval in the grounding flow.
Signature:
retrievalMetadata?: RetrievalMetadata;Reference Main Generative Ai.Groundingmetadata.Searchentrypoint (`docs/reference/main/generative-ai.groundingmetadata.searchentrypoint.md`)
Home > @google/generative-ai > GroundingMetadata > searchEntryPoint
GroundingMetadata.searchEntryPoint property
Google search entry for the following-up web searches.
Signature:
searchEntryPoint?: SearchEntryPoint;Reference Main Generative Ai.Groundingmetadata.Websearchqueries (`docs/reference/main/generative-ai.groundingmetadata.websearchqueries.md`)
Home > @google/generative-ai > GroundingMetadata > webSearchQueries
GroundingMetadata.webSearchQueries property
* Web search queries for the following-up web search.
Signature:
webSearchQueries: string[];Reference Main Generative Ai.Groundingsupport.Confidencescores (`docs/reference/main/generative-ai.groundingsupport.confidencescores.md`)
Home > @google/generative-ai > GroundingSupport > confidenceScores
GroundingSupport.confidenceScores property
Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices.
Signature:
confidenceScores?: number[];Reference Main Generative Ai.Groundingsupport.Groundingchunckindices (`docs/reference/main/generative-ai.groundingsupport.groundingchunckindices.md`)
Home > @google/generative-ai > GroundingSupport > groundingChunckIndices
GroundingSupport.groundingChunckIndices property
A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim.
Signature:
groundingChunckIndices?: number[];Reference Main Generative Ai.Groundingsupport (`docs/reference/main/generative-ai.groundingsupport.md`)
Home > @google/generative-ai > GroundingSupport
GroundingSupport interface
Grounding support.
Signature:
export declare interface GroundingSupportProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| confidenceScores? | number[] | (Optional) Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the grounding_chunk_indices. | |
| groundingChunckIndices? | number[] | (Optional) A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim. | |
| segment? | string | (Optional) URI reference of the chunk. |
Reference Main Generative Ai.Groundingsupport.Segment (`docs/reference/main/generative-ai.groundingsupport.segment.md`)
Home > @google/generative-ai > GroundingSupport > segment
GroundingSupport.segment property
URI reference of the chunk.
Signature:
segment?: string;Reference Main Generative Ai.Groundingsupportsegment (`docs/reference/main/generative-ai.groundingsupportsegment.md`)
Home > @google/generative-ai > GroundingSupportSegment
GroundingSupportSegment interface
Segment of the content.
Signature:
export declare interface GroundingSupportSegmentProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| endIndex? | number | (Optional) End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero. | |
| partIndex? | number | (Optional) The index of a Part object within its parent Content object. | |
| startIndex? | number | (Optional) Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero. | |
| text? | string | (Optional) The text corresponding to the segment from the response. |
Reference Main Generative Ai.Groundingsupportsegment.Text (`docs/reference/main/generative-ai.groundingsupportsegment.text.md`)
Home > @google/generative-ai > GroundingSupportSegment > text
GroundingSupportSegment.text property
The text corresponding to the segment from the response.
Signature:
text?: string;Reference Main Generative Ai.Harmblockthreshold (`docs/reference/main/generative-ai.harmblockthreshold.md`)
Home > @google/generative-ai > HarmBlockThreshold
HarmBlockThreshold enum
Threshold above which a prompt or candidate will be blocked.
Signature:
export declare enum HarmBlockThresholdEnumeration Members
| Member | Value | Description |
|---|---|---|
| BLOCK_LOW_AND_ABOVE | "BLOCK_LOW_AND_ABOVE" |
Content with NEGLIGIBLE will be allowed. |
| BLOCK_MEDIUM_AND_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" |
Content with NEGLIGIBLE and LOW will be allowed. |
| BLOCK_NONE | "BLOCK_NONE" |
All content will be allowed. |
| BLOCK_ONLY_HIGH | "BLOCK_ONLY_HIGH" |
Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed. |
| HARM_BLOCK_THRESHOLD_UNSPECIFIED | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" |
Threshold is unspecified. |
Reference Main Generative Ai.Harmcategory (`docs/reference/main/generative-ai.harmcategory.md`)
Home > @google/generative-ai > HarmCategory
HarmCategory enum
Harm categories that would cause prompts or candidates to be blocked.
Signature:
export declare enum HarmCategoryEnumeration Members
| Member | Value | Description |
|---|---|---|
| HARM_CATEGORY_CIVIC_INTEGRITY | "HARM_CATEGORY_CIVIC_INTEGRITY" |
|
| HARM_CATEGORY_DANGEROUS_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" |
|
| HARM_CATEGORY_HARASSMENT | "HARM_CATEGORY_HARASSMENT" |
|
| HARM_CATEGORY_HATE_SPEECH | "HARM_CATEGORY_HATE_SPEECH" |
|
| HARM_CATEGORY_SEXUALLY_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" |
|
| HARM_CATEGORY_UNSPECIFIED | "HARM_CATEGORY_UNSPECIFIED" |
Reference Main Generative Ai.Harmprobability (`docs/reference/main/generative-ai.harmprobability.md`)
Home > @google/generative-ai > HarmProbability
HarmProbability enum
Probability that a prompt or candidate matches a harm category.
Signature:
export declare enum HarmProbabilityEnumeration Members
| Member | Value | Description |
|---|---|---|
| HARM_PROBABILITY_UNSPECIFIED | "HARM_PROBABILITY_UNSPECIFIED" |
Probability is unspecified. |
| HIGH | "HIGH" |
Content has a high chance of being unsafe. |
| LOW | "LOW" |
Content has a low chance of being unsafe. |
| MEDIUM | "MEDIUM" |
Content has a medium chance of being unsafe. |
| NEGLIGIBLE | "NEGLIGIBLE" |
Content has a negligible chance of being unsafe. |
Reference Main Generative Ai.Inlinedatapart.Codeexecutionresult (`docs/reference/main/generative-ai.inlinedatapart.codeexecutionresult.md`)
Home > @google/generative-ai > InlineDataPart > codeExecutionResult
InlineDataPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Inlinedatapart.Executablecode (`docs/reference/main/generative-ai.inlinedatapart.executablecode.md`)
Home > @google/generative-ai > InlineDataPart > executableCode
InlineDataPart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Inlinedatapart.Filedata (`docs/reference/main/generative-ai.inlinedatapart.filedata.md`)
Home > @google/generative-ai > InlineDataPart > fileData
InlineDataPart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Inlinedatapart.Functioncall (`docs/reference/main/generative-ai.inlinedatapart.functioncall.md`)
Home > @google/generative-ai > InlineDataPart > functionCall
InlineDataPart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Inlinedatapart.Functionresponse (`docs/reference/main/generative-ai.inlinedatapart.functionresponse.md`)
Home > @google/generative-ai > InlineDataPart > functionResponse
InlineDataPart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Inlinedatapart.Inlinedata (`docs/reference/main/generative-ai.inlinedatapart.inlinedata.md`)
Home > @google/generative-ai > InlineDataPart > inlineData
InlineDataPart.inlineData property
Signature:
inlineData: GenerativeContentBlob;Reference Main Generative Ai.Inlinedatapart (`docs/reference/main/generative-ai.inlinedatapart.md`)
Home > @google/generative-ai > InlineDataPart
InlineDataPart interface
Content part interface if the part represents an image.
Signature:
export interface InlineDataPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData | GenerativeContentBlob | ||
| text? | never | (Optional) |
Reference Main Generative Ai.Inlinedatapart.Text (`docs/reference/main/generative-ai.inlinedatapart.text.md`)
Home > @google/generative-ai > InlineDataPart > text
InlineDataPart.text property
Signature:
text?: never;Reference Main Generative Ai.Integerschema.Format (`docs/reference/main/generative-ai.integerschema.format.md`)
Home > @google/generative-ai > IntegerSchema > format
IntegerSchema.format property
Optional. The format of the number.
Signature:
format?: "int32" | "int64";Reference Main Generative Ai.Integerschema (`docs/reference/main/generative-ai.integerschema.md`)
Home > @google/generative-ai > IntegerSchema
IntegerSchema interface
Describes a JSON-encodable integer.
Signature:
export interface IntegerSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| format? | "int32" | "int64" | (Optional) Optional. The format of the number. | |
| type | typeof SchemaType.INTEGER |
Reference Main Generative Ai.Integerschema.Type (`docs/reference/main/generative-ai.integerschema.type.md`)
Home > @google/generative-ai > IntegerSchema > type
IntegerSchema.type property
Signature:
type: typeof SchemaType.INTEGER;Reference Main Generative Ai.Logprobscandidate.Logprobability (`docs/reference/main/generative-ai.logprobscandidate.logprobability.md`)
Home > @google/generative-ai > LogprobsCandidate > logProbability
LogprobsCandidate.logProbability property
The candidate's log probability.
Signature:
logProbability: number;Reference Main Generative Ai.Logprobscandidate (`docs/reference/main/generative-ai.logprobscandidate.md`)
Home > @google/generative-ai > LogprobsCandidate
LogprobsCandidate interface
Candidate for the logprobs token and score.
Signature:
export interface LogprobsCandidateProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| logProbability | number | The candidate's log probability. | |
| token | string | The candidate's token string value. | |
| tokenID | number | The candidate's token id value. |
Reference Main Generative Ai.Logprobscandidate.Token (`docs/reference/main/generative-ai.logprobscandidate.token.md`)
Home > @google/generative-ai > LogprobsCandidate > token
LogprobsCandidate.token property
The candidate's token string value.
Signature:
token: string;Reference Main Generative Ai.Logprobscandidate.Tokenid (`docs/reference/main/generative-ai.logprobscandidate.tokenid.md`)
Home > @google/generative-ai > LogprobsCandidate > tokenID
LogprobsCandidate.tokenID property
The candidate's token id value.
Signature:
tokenID: number;Reference Main Generative Ai.Logprobsresult.Chosencandidates (`docs/reference/main/generative-ai.logprobsresult.chosencandidates.md`)
Home > @google/generative-ai > LogprobsResult > chosenCandidates
LogprobsResult.chosenCandidates property
Length = total number of decoding steps. The chosen candidates may or may not be in topCandidates.
Signature:
chosenCandidates: LogprobsCandidate[];Reference Main Generative Ai.Logprobsresult (`docs/reference/main/generative-ai.logprobsresult.md`)
Home > @google/generative-ai > LogprobsResult
LogprobsResult interface
Logprobs Result
Signature:
export interface LogprobsResultProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| chosenCandidates | LogprobsCandidate[] | Length = total number of decoding steps. The chosen candidates may or may not be in topCandidates. | |
| topCandidates | TopCandidates[] | Length = total number of decoding steps. |
Reference Main Generative Ai.Logprobsresult.Topcandidates (`docs/reference/main/generative-ai.logprobsresult.topcandidates.md`)
Home > @google/generative-ai > LogprobsResult > topCandidates
LogprobsResult.topCandidates property
Length = total number of decoding steps.
Signature:
topCandidates: TopCandidates[];Reference Main Generative Ai (`docs/reference/main/generative-ai.md`)
generative-ai package
Classes
| Class | Description |
|---|---|
| ChatSession | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. |
| GenerativeModel | Class for generative model APIs. |
| GoogleGenerativeAI | Top-level class for this SDK |
| GoogleGenerativeAIAbortError | Error thrown when a request is aborted, either due to a timeout or intentional cancellation by the user. |
| GoogleGenerativeAIError | Basic error type for this SDK. |
| GoogleGenerativeAIFetchError | Error class covering HTTP errors when calling the server. Includes HTTP status, statusText, and optional details, if provided in the server response. |
| GoogleGenerativeAIRequestInputError | Errors in the contents of a request originating from user input. |
| GoogleGenerativeAIResponseError | Errors in the contents of a response from the model. This includes parsing errors, or responses including a safety block reason. |
Enumerations
| Enumeration | Description |
|---|---|
| BlockReason | Reason that a prompt was blocked. |
| DynamicRetrievalMode | The mode of the predictor to be used in dynamic retrieval. |
| ExecutableCodeLanguage | |
| FinishReason | Reason that a candidate finished. |
| FunctionCallingMode | |
| HarmBlockThreshold | Threshold above which a prompt or candidate will be blocked. |
| HarmCategory | Harm categories that would cause prompts or candidates to be blocked. |
| HarmProbability | Probability that a prompt or candidate matches a harm category. |
| Outcome | Possible outcomes of code execution. |
| SchemaType | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ |
| TaskType | Task type for embedding content. |
Interfaces
| Interface | Description |
|---|---|
| ArraySchema | Describes an array, an ordered list of values. |
| BaseParams | Base parameters for a number of methods. |
| BatchEmbedContentsRequest | Params for calling GenerativeModel.batchEmbedContents() |
| BatchEmbedContentsResponse | Response from calling GenerativeModel.batchEmbedContents(). |
| BooleanSchema | Describes a boolean, either 'true' or 'false'. |
| CachedContent | Describes CachedContent interface for sending to the server (if creating) or received from the server (using getters or list methods). |
| CachedContentBase | |
| CitationMetadata | Citation metadata that may be found on a GenerateContentCandidate. |
| CitationSource | A single citation source. |
| CodeExecutionResult | Result of executing the ExecutableCode. Only generated when using code execution, and always follows a Part containing the ExecutableCode. |
| CodeExecutionResultPart | Content part containing the result of executed code. |
| CodeExecutionTool | Enables the model to execute code as part of generation. |
| Content | Content type for both prompts and response candidates. |
| ContentEmbedding | A single content embedding. |
| CountTokensRequest | Params for calling GenerativeModel.countTokens().The request must contain either a Content array or a GenerateContentRequest, but not both. If both are provided then a GoogleGenerativeAIRequestInputError is thrown. |
| CountTokensResponse | Response from calling GenerativeModel.countTokens(). |
| DynamicRetrievalConfig | Specifies the dynamic retrieval configuration for the given source. |
| EmbedContentRequest | Params for calling GenerativeModel.embedContent() |
| EmbedContentResponse | Response from calling GenerativeModel.embedContent(). |
| EnhancedGenerateContentResponse | Response object wrapped with helper methods. |
| EnumStringSchema | Describes a string enum |
| ErrorDetails | Details object that may be included in an error response. |
| ExecutableCode | Code generated by the model that is meant to be executed, where the result is returned to the model. Only generated when using the code execution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated. |
| ExecutableCodePart | Content part containing executable code generated by the model. |
| FileData | Data pointing to a file uploaded with the Files API. |
| FileDataPart | Content part interface if the part represents FileData. |
| FunctionCall | A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing the parameters and their values. |
| FunctionCallingConfig | |
| FunctionCallPart | Content part interface if the part represents a FunctionCall. |
| FunctionDeclaration | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. |
| FunctionDeclarationSchema | Schema for parameters passed to FunctionDeclaration.parameters. |
| FunctionDeclarationsTool | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. |
| FunctionResponse | The result output from a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall] made based on model prediction. |
| FunctionResponsePart | Content part interface if the part represents FunctionResponse. |
| GenerateContentCandidate | A candidate returned as part of a GenerateContentResponse. |
| GenerateContentRequest | Request sent to generateContent endpoint. |
| GenerateContentResponse | Individual response from GenerativeModel.generateContent() and GenerativeModel.generateContentStream(). generateContentStream() will return one in each chunk until the stream is done. |
| GenerateContentResult | Result object returned from generateContent() call. |
| GenerateContentStreamResult | Result object returned from generateContentStream() call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. |
| GenerationConfig | Config options for content-related requests |
| GenerativeContentBlob | Interface for sending an image. |
| GoogleSearchRetrieval | Retrieval tool that is powered by Google search. |
| GoogleSearchRetrievalTool | Retrieval tool that is powered by Google search. |
| GroundingChunk | Grounding chunk. |
| GroundingChunkWeb | Chunk from the web. |
| GroundingMetadata | Metadata returned to client when grounding is enabled. |
| GroundingSupport | Grounding support. |
| GroundingSupportSegment | Segment of the content. |
| InlineDataPart | Content part interface if the part represents an image. |
| IntegerSchema | Describes a JSON-encodable integer. |
| LogprobsCandidate | Candidate for the logprobs token and score. |
| LogprobsResult | Logprobs Result |
| ModelParams | Params passed to GoogleGenerativeAI.getGenerativeModel(). |
| NumberSchema | Describes a JSON-encodable floating point number. |
| ObjectSchema | Describes a JSON object, a mapping of specific keys to values. |
| PromptFeedback | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. |
| RequestOptions | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
| RetrievalMetadata | Metadata related to retrieval in the grounding flow. |
| SafetyRating | A safety rating associated with a GenerateContentCandidate |
| SafetySetting | Safety setting that can be sent as part of request parameters. |
| SearchEntryPoint | Google search entry point. |
| SimpleStringSchema | Describes a simple string schema, with or without format |
| SingleRequestOptions | Params passed to atomic asynchronous operations. |
| StartChatParams | Params for GenerativeModel.startChat(). |
| TextPart | Content part interface if the part represents a text string. |
| ToolConfig | Tool config. This config is shared for all tools provided in the request. |
| TopCandidates | Candidates with top log probabilities at each decoding step |
| UsageMetadata | Metadata on the generation request's token usage. |
Variables
| Variable | Description |
|---|---|
| POSSIBLE_ROLES | Possible roles. |
Type Aliases
| Type Alias | Description |
|---|---|
| FunctionDeclarationSchemaProperty | Schema for top-level function declaration |
| Part | Content part - includes text or image part types. |
| ResponseSchema | Schema passed to GenerationConfig.responseSchema |
| Schema | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. |
| StringSchema | Describes a string. |
| Tool | Defines a tool that model can call to access external knowledge. |
Reference Main Generative Ai.Modelparams.Cachedcontent (`docs/reference/main/generative-ai.modelparams.cachedcontent.md`)
Home > @google/generative-ai > ModelParams > cachedContent
ModelParams.cachedContent property
Signature:
cachedContent?: CachedContent;Reference Main Generative Ai.Modelparams (`docs/reference/main/generative-ai.modelparams.md`)
Home > @google/generative-ai > ModelParams
ModelParams interface
Params passed to GoogleGenerativeAI.getGenerativeModel().
Signature:
export interface ModelParams extends BaseParamsExtends: BaseParams
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContent? | CachedContent | (Optional) | |
| model | string | ||
| systemInstruction? | string | Part | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Reference Main Generative Ai.Modelparams.Model (`docs/reference/main/generative-ai.modelparams.model.md`)
Home > @google/generative-ai > ModelParams > model
ModelParams.model property
Signature:
model: string;Reference Main Generative Ai.Modelparams.Systeminstruction (`docs/reference/main/generative-ai.modelparams.systeminstruction.md`)
Home > @google/generative-ai > ModelParams > systemInstruction
ModelParams.systemInstruction property
Signature:
systemInstruction?: string | Part | Content;Reference Main Generative Ai.Modelparams.Toolconfig (`docs/reference/main/generative-ai.modelparams.toolconfig.md`)
Home > @google/generative-ai > ModelParams > toolConfig
ModelParams.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Main Generative Ai.Modelparams.Tools (`docs/reference/main/generative-ai.modelparams.tools.md`)
Home > @google/generative-ai > ModelParams > tools
ModelParams.tools property
Signature:
tools?: Tool[];Reference Main Generative Ai.Numberschema.Format (`docs/reference/main/generative-ai.numberschema.format.md`)
Home > @google/generative-ai > NumberSchema > format
NumberSchema.format property
Optional. The format of the number.
Signature:
format?: "float" | "double";Reference Main Generative Ai.Numberschema (`docs/reference/main/generative-ai.numberschema.md`)
Home > @google/generative-ai > NumberSchema
NumberSchema interface
Describes a JSON-encodable floating point number.
Signature:
export interface NumberSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| format? | "float" | "double" | (Optional) Optional. The format of the number. | |
| type | typeof SchemaType.NUMBER |
Reference Main Generative Ai.Numberschema.Type (`docs/reference/main/generative-ai.numberschema.type.md`)
Home > @google/generative-ai > NumberSchema > type
NumberSchema.type property
Signature:
type: typeof SchemaType.NUMBER;Reference Main Generative Ai.Objectschema (`docs/reference/main/generative-ai.objectschema.md`)
Home > @google/generative-ai > ObjectSchema
ObjectSchema interface
Describes a JSON object, a mapping of specific keys to values.
Signature:
export interface ObjectSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| properties | { [k: string]: Schema; } | Describes the properties of the JSON object. Must not be empty. | |
| required? | string[] | (Optional) A list of keys declared in the properties object. Required properties will always be present in the generated object. | |
| type | typeof SchemaType.OBJECT |
Reference Main Generative Ai.Objectschema.Properties (`docs/reference/main/generative-ai.objectschema.properties.md`)
Home > @google/generative-ai > ObjectSchema > properties
ObjectSchema.properties property
Describes the properties of the JSON object. Must not be empty.
Signature:
properties: {
[k: string]: Schema;
};Reference Main Generative Ai.Objectschema.Required (`docs/reference/main/generative-ai.objectschema.required.md`)
Home > @google/generative-ai > ObjectSchema > required
ObjectSchema.required property
A list of keys declared in the properties object. Required properties will always be present in the generated object.
Signature:
required?: string[];Reference Main Generative Ai.Objectschema.Type (`docs/reference/main/generative-ai.objectschema.type.md`)
Home > @google/generative-ai > ObjectSchema > type
ObjectSchema.type property
Signature:
type: typeof SchemaType.OBJECT;Reference Main Generative Ai.Outcome (`docs/reference/main/generative-ai.outcome.md`)
Home > @google/generative-ai > Outcome
Outcome enum
Possible outcomes of code execution.
Signature:
export declare enum OutcomeEnumeration Members
| Member | Value | Description |
|---|---|---|
| OUTCOME_DEADLINE_EXCEEDED | "outcome_deadline_exceeded" |
Code execution ran for too long, and was cancelled. There may or may not be a partial output present. |
| OUTCOME_FAILED | "outcome_failed" |
Code execution finished but with a failure. stderr should contain the reason. |
| OUTCOME_OK | "outcome_ok" |
Code execution completed successfully. |
| OUTCOME_UNSPECIFIED | "outcome_unspecified" |
Unspecified status. This value should not be used. |
Reference Main Generative Ai.Part (`docs/reference/main/generative-ai.part.md`)
Home > @google/generative-ai > Part
Part type
Content part - includes text or image part types.
Signature:
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;References: TextPart, InlineDataPart, FunctionCallPart, FunctionResponsePart, FileDataPart, ExecutableCodePart, CodeExecutionResultPart
Reference Main Generative Ai.Possible Roles (`docs/reference/main/generative-ai.possible_roles.md`)
Home > @google/generative-ai > POSSIBLE_ROLES
POSSIBLE\_ROLES variable
Possible roles.
Signature:
POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]Reference Main Generative Ai.Promptfeedback.Blockreason (`docs/reference/main/generative-ai.promptfeedback.blockreason.md`)
Home > @google/generative-ai > PromptFeedback > blockReason
PromptFeedback.blockReason property
Signature:
blockReason: BlockReason;Reference Main Generative Ai.Promptfeedback.Blockreasonmessage (`docs/reference/main/generative-ai.promptfeedback.blockreasonmessage.md`)
Home > @google/generative-ai > PromptFeedback > blockReasonMessage
PromptFeedback.blockReasonMessage property
Signature:
blockReasonMessage?: string;Reference Main Generative Ai.Promptfeedback (`docs/reference/main/generative-ai.promptfeedback.md`)
Home > @google/generative-ai > PromptFeedback
PromptFeedback interface
If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings.
Signature:
export interface PromptFeedbackProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| blockReason | BlockReason | ||
| blockReasonMessage? | string | (Optional) | |
| safetyRatings | SafetyRating[] |
Reference Main Generative Ai.Promptfeedback.Safetyratings (`docs/reference/main/generative-ai.promptfeedback.safetyratings.md`)
Home > @google/generative-ai > PromptFeedback > safetyRatings
PromptFeedback.safetyRatings property
Signature:
safetyRatings: SafetyRating[];Reference Main Generative Ai.Requestoptions.Apiclient (`docs/reference/main/generative-ai.requestoptions.apiclient.md`)
Home > @google/generative-ai > RequestOptions > apiClient
RequestOptions.apiClient property
Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs.
Signature:
apiClient?: string;Reference Main Generative Ai.Requestoptions.Apiversion (`docs/reference/main/generative-ai.requestoptions.apiversion.md`)
Home > @google/generative-ai > RequestOptions > apiVersion
RequestOptions.apiVersion property
Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version.
Signature:
apiVersion?: string;Reference Main Generative Ai.Requestoptions.Baseurl (`docs/reference/main/generative-ai.requestoptions.baseurl.md`)
Home > @google/generative-ai > RequestOptions > baseUrl
RequestOptions.baseUrl property
Base endpoint url. Defaults to "https://generativelanguage.googleapis.com"
Signature:
baseUrl?: string;Reference Main Generative Ai.Requestoptions.Customheaders (`docs/reference/main/generative-ai.requestoptions.customheaders.md`)
Home > @google/generative-ai > RequestOptions > customHeaders
RequestOptions.customHeaders property
Custom HTTP request headers.
Signature:
customHeaders?: Headers | Record<string, string>;Reference Main Generative Ai.Requestoptions (`docs/reference/main/generative-ai.requestoptions.md`)
Home > @google/generative-ai > RequestOptions
RequestOptions interface
Params passed to getGenerativeModel() or GoogleAIFileManager().
Signature:
export interface RequestOptionsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiClient? | string | (Optional) Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs. | |
| apiVersion? | string | (Optional) Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version. | |
| baseUrl? | string | (Optional) Base endpoint url. Defaults to "https://generativelanguage.googleapis.com" | |
| customHeaders? | Headers | Record<string, string> | (Optional) Custom HTTP request headers. | |
| timeout? | number | (Optional) Request timeout in milliseconds. |
Reference Main Generative Ai.Requestoptions.Timeout (`docs/reference/main/generative-ai.requestoptions.timeout.md`)
Home > @google/generative-ai > RequestOptions > timeout
RequestOptions.timeout property
Request timeout in milliseconds.
Signature:
timeout?: number;Reference Main Generative Ai.Responseschema (`docs/reference/main/generative-ai.responseschema.md`)
Home > @google/generative-ai > ResponseSchema
ResponseSchema type
Schema passed to GenerationConfig.responseSchema
Signature:
export type ResponseSchema = Schema;References: Schema
Reference Main Generative Ai.Retrievalmetadata.Googlesearchdynamicretrievalscore (`docs/reference/main/generative-ai.retrievalmetadata.googlesearchdynamicretrievalscore.md`)
Home > @google/generative-ai > RetrievalMetadata > googleSearchDynamicRetrievalScore
RetrievalMetadata.googleSearchDynamicRetrievalScore property
Score indicating how likely information from google search could help answer the prompt. The score is in the range [0, 1], where 0 is the least likely and 1 is the most likely. This score is only populated when google search grounding and dynamic retrieval is enabled. It will becompared to the threshold to determine whether to trigger google search.
Signature:
googleSearchDynamicRetrievalScore?: number;Reference Main Generative Ai.Retrievalmetadata (`docs/reference/main/generative-ai.retrievalmetadata.md`)
Home > @google/generative-ai > RetrievalMetadata
RetrievalMetadata interface
Metadata related to retrieval in the grounding flow.
Signature:
export declare interface RetrievalMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| googleSearchDynamicRetrievalScore? | number | (Optional) Score indicating how likely information from google search could help answer the prompt. The score is in the range [0, 1], where 0 is the least likely and 1 is the most likely. This score is only populated when google search grounding and dynamic retrieval is enabled. It will becompared to the threshold to determine whether to trigger google search. |
Reference Main Generative Ai.Safetyrating.Category (`docs/reference/main/generative-ai.safetyrating.category.md`)
Home > @google/generative-ai > SafetyRating > category
SafetyRating.category property
Signature:
category: HarmCategory;Reference Main Generative Ai.Safetyrating (`docs/reference/main/generative-ai.safetyrating.md`)
Home > @google/generative-ai > SafetyRating
SafetyRating interface
A safety rating associated with a GenerateContentCandidate
Signature:
export interface SafetyRatingProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| category | HarmCategory | ||
| probability | HarmProbability |
Reference Main Generative Ai.Safetyrating.Probability (`docs/reference/main/generative-ai.safetyrating.probability.md`)
Home > @google/generative-ai > SafetyRating > probability
SafetyRating.probability property
Signature:
probability: HarmProbability;Reference Main Generative Ai.Safetysetting.Category (`docs/reference/main/generative-ai.safetysetting.category.md`)
Home > @google/generative-ai > SafetySetting > category
SafetySetting.category property
Signature:
category: HarmCategory;Reference Main Generative Ai.Safetysetting (`docs/reference/main/generative-ai.safetysetting.md`)
Home > @google/generative-ai > SafetySetting
SafetySetting interface
Safety setting that can be sent as part of request parameters.
Signature:
export interface SafetySettingProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| category | HarmCategory | ||
| threshold | HarmBlockThreshold |
Reference Main Generative Ai.Safetysetting.Threshold (`docs/reference/main/generative-ai.safetysetting.threshold.md`)
Home > @google/generative-ai > SafetySetting > threshold
SafetySetting.threshold property
Signature:
threshold: HarmBlockThreshold;Reference Main Generative Ai.Schema (`docs/reference/main/generative-ai.schema.md`)
Home > @google/generative-ai > Schema
Schema type
Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.
Signature:
export type Schema = StringSchema | NumberSchema | IntegerSchema | BooleanSchema | ArraySchema | ObjectSchema;References: StringSchema, NumberSchema, IntegerSchema, BooleanSchema, ArraySchema, ObjectSchema
Reference Main Generative Ai.Schematype (`docs/reference/main/generative-ai.schematype.md`)
Home > @google/generative-ai > SchemaType
SchemaType enum
Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/
Signature:
export declare enum SchemaTypeEnumeration Members
| Member | Value | Description |
|---|---|---|
| ARRAY | "array" |
Array type. |
| BOOLEAN | "boolean" |
Boolean type. |
| INTEGER | "integer" |
Integer type. |
| NUMBER | "number" |
Number type. |
| OBJECT | "object" |
Object type. |
| STRING | "string" |
String type. |
Reference Main Generative Ai.Searchentrypoint (`docs/reference/main/generative-ai.searchentrypoint.md`)
Home > @google/generative-ai > SearchEntryPoint
SearchEntryPoint interface
Google search entry point.
Signature:
export declare interface SearchEntryPointProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| renderedContent? | string | (Optional) Web content snippet that can be embedded in a web page or an app webview. | |
| sdkBlob? | string | (Optional) Base64 encoded JSON representing array of <search term, search url> tuple. |
Reference Main Generative Ai.Searchentrypoint.Renderedcontent (`docs/reference/main/generative-ai.searchentrypoint.renderedcontent.md`)
Home > @google/generative-ai > SearchEntryPoint > renderedContent
SearchEntryPoint.renderedContent property
Web content snippet that can be embedded in a web page or an app webview.
Signature:
renderedContent?: string;Reference Main Generative Ai.Searchentrypoint.Sdkblob (`docs/reference/main/generative-ai.searchentrypoint.sdkblob.md`)
Home > @google/generative-ai > SearchEntryPoint > sdkBlob
SearchEntryPoint.sdkBlob property
Base64 encoded JSON representing array of <search term, search url> tuple.
Signature:
sdkBlob?: string;Reference Main Generative Ai.Simplestringschema.Enum (`docs/reference/main/generative-ai.simplestringschema.enum.md`)
Home > @google/generative-ai > SimpleStringSchema > enum
SimpleStringSchema.enum property
Signature:
enum?: never;Reference Main Generative Ai.Simplestringschema.Format (`docs/reference/main/generative-ai.simplestringschema.format.md`)
Home > @google/generative-ai > SimpleStringSchema > format
SimpleStringSchema.format property
Signature:
format?: "date-time" | undefined;Reference Main Generative Ai.Simplestringschema (`docs/reference/main/generative-ai.simplestringschema.md`)
Home > @google/generative-ai > SimpleStringSchema
SimpleStringSchema interface
Describes a simple string schema, with or without format
Signature:
export interface SimpleStringSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| enum? | never | (Optional) | |
| format? | "date-time" | undefined | (Optional) | |
| type | typeof SchemaType.STRING |
Reference Main Generative Ai.Simplestringschema.Type (`docs/reference/main/generative-ai.simplestringschema.type.md`)
Home > @google/generative-ai > SimpleStringSchema > type
SimpleStringSchema.type property
Signature:
type: typeof SchemaType.STRING;Reference Main Generative Ai.Singlerequestoptions (`docs/reference/main/generative-ai.singlerequestoptions.md`)
Home > @google/generative-ai > SingleRequestOptions
SingleRequestOptions interface
Params passed to atomic asynchronous operations.
Signature:
export interface SingleRequestOptions extends RequestOptionsExtends: RequestOptions
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| signal? | AbortSignal | (Optional) An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided.NOTE: AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations. |
Reference Main Generative Ai.Singlerequestoptions.Signal (`docs/reference/main/generative-ai.singlerequestoptions.signal.md`)
Home > @google/generative-ai > SingleRequestOptions > signal
SingleRequestOptions.signal property
An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided.
NOTE: AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations.
Signature:
signal?: AbortSignal;Reference Main Generative Ai.Startchatparams.Cachedcontent (`docs/reference/main/generative-ai.startchatparams.cachedcontent.md`)
Home > @google/generative-ai > StartChatParams > cachedContent
StartChatParams.cachedContent property
This is the name of a CachedContent and not the cache object itself.
Signature:
cachedContent?: string;Reference Main Generative Ai.Startchatparams.History (`docs/reference/main/generative-ai.startchatparams.history.md`)
Home > @google/generative-ai > StartChatParams > history
StartChatParams.history property
Signature:
history?: Content[];Reference Main Generative Ai.Startchatparams (`docs/reference/main/generative-ai.startchatparams.md`)
Home > @google/generative-ai > StartChatParams
StartChatParams interface
Params for GenerativeModel.startChat().
Signature:
export interface StartChatParams extends BaseParamsExtends: BaseParams
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContent? | string | (Optional) This is the name of a CachedContent and not the cache object itself. |
|
| history? | Content[] | (Optional) | |
| systemInstruction? | string | Part | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Reference Main Generative Ai.Startchatparams.Systeminstruction (`docs/reference/main/generative-ai.startchatparams.systeminstruction.md`)
Home > @google/generative-ai > StartChatParams > systemInstruction
StartChatParams.systemInstruction property
Signature:
systemInstruction?: string | Part | Content;Reference Main Generative Ai.Startchatparams.Toolconfig (`docs/reference/main/generative-ai.startchatparams.toolconfig.md`)
Home > @google/generative-ai > StartChatParams > toolConfig
StartChatParams.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Main Generative Ai.Startchatparams.Tools (`docs/reference/main/generative-ai.startchatparams.tools.md`)
Home > @google/generative-ai > StartChatParams > tools
StartChatParams.tools property
Signature:
tools?: Tool[];Reference Main Generative Ai.Stringschema (`docs/reference/main/generative-ai.stringschema.md`)
Home > @google/generative-ai > StringSchema
StringSchema type
Describes a string.
Signature:
export type StringSchema = SimpleStringSchema | EnumStringSchema;References: SimpleStringSchema, EnumStringSchema
Reference Main Generative Ai.Tasktype (`docs/reference/main/generative-ai.tasktype.md`)
Home > @google/generative-ai > TaskType
TaskType enum
Task type for embedding content.
Signature:
export declare enum TaskTypeEnumeration Members
| Member | Value | Description |
|---|---|---|
| CLASSIFICATION | "CLASSIFICATION" |
|
| CLUSTERING | "CLUSTERING" |
|
| RETRIEVAL_DOCUMENT | "RETRIEVAL_DOCUMENT" |
|
| RETRIEVAL_QUERY | "RETRIEVAL_QUERY" |
|
| SEMANTIC_SIMILARITY | "SEMANTIC_SIMILARITY" |
|
| TASK_TYPE_UNSPECIFIED | "TASK_TYPE_UNSPECIFIED" |
Reference Main Generative Ai.Textpart.Codeexecutionresult (`docs/reference/main/generative-ai.textpart.codeexecutionresult.md`)
Home > @google/generative-ai > TextPart > codeExecutionResult
TextPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Main Generative Ai.Textpart.Executablecode (`docs/reference/main/generative-ai.textpart.executablecode.md`)
Home > @google/generative-ai > TextPart > executableCode
TextPart.executableCode property
Signature:
executableCode?: never;Reference Main Generative Ai.Textpart.Filedata (`docs/reference/main/generative-ai.textpart.filedata.md`)
Home > @google/generative-ai > TextPart > fileData
TextPart.fileData property
Signature:
fileData?: never;Reference Main Generative Ai.Textpart.Functioncall (`docs/reference/main/generative-ai.textpart.functioncall.md`)
Home > @google/generative-ai > TextPart > functionCall
TextPart.functionCall property
Signature:
functionCall?: never;Reference Main Generative Ai.Textpart.Functionresponse (`docs/reference/main/generative-ai.textpart.functionresponse.md`)
Home > @google/generative-ai > TextPart > functionResponse
TextPart.functionResponse property
Signature:
functionResponse?: never;Reference Main Generative Ai.Textpart.Inlinedata (`docs/reference/main/generative-ai.textpart.inlinedata.md`)
Home > @google/generative-ai > TextPart > inlineData
TextPart.inlineData property
Signature:
inlineData?: never;Reference Main Generative Ai.Textpart (`docs/reference/main/generative-ai.textpart.md`)
Home > @google/generative-ai > TextPart
TextPart interface
Content part interface if the part represents a text string.
Signature:
export interface TextPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text | string |
Reference Main Generative Ai.Textpart.Text (`docs/reference/main/generative-ai.textpart.text.md`)
Home > @google/generative-ai > TextPart > text
TextPart.text property
Signature:
text: string;Reference Main Generative Ai.Tool (`docs/reference/main/generative-ai.tool.md`)
Home > @google/generative-ai > Tool
Tool type
Defines a tool that model can call to access external knowledge.
Signature:
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool | GoogleSearchRetrievalTool;References: FunctionDeclarationsTool, CodeExecutionTool, GoogleSearchRetrievalTool
Reference Main Generative Ai.Toolconfig.Functioncallingconfig (`docs/reference/main/generative-ai.toolconfig.functioncallingconfig.md`)
Home > @google/generative-ai > ToolConfig > functionCallingConfig
ToolConfig.functionCallingConfig property
Signature:
functionCallingConfig: FunctionCallingConfig;Reference Main Generative Ai.Toolconfig (`docs/reference/main/generative-ai.toolconfig.md`)
Home > @google/generative-ai > ToolConfig
ToolConfig interface
Tool config. This config is shared for all tools provided in the request.
Signature:
export interface ToolConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| functionCallingConfig | FunctionCallingConfig |
Reference Main Generative Ai.Topcandidates.Candidates (`docs/reference/main/generative-ai.topcandidates.candidates.md`)
Home > @google/generative-ai > TopCandidates > candidates
TopCandidates.candidates property
Sorted by log probability in descending order.
Signature:
candidates: LogprobsCandidate[];Reference Main Generative Ai.Topcandidates (`docs/reference/main/generative-ai.topcandidates.md`)
Home > @google/generative-ai > TopCandidates
TopCandidates interface
Candidates with top log probabilities at each decoding step
Signature:
export interface TopCandidatesProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| candidates | LogprobsCandidate[] | Sorted by log probability in descending order. |
Reference Main Generative Ai.Usagemetadata.Cachedcontenttokencount (`docs/reference/main/generative-ai.usagemetadata.cachedcontenttokencount.md`)
Home > @google/generative-ai > UsageMetadata > cachedContentTokenCount
UsageMetadata.cachedContentTokenCount property
Total token count in the cached part of the prompt, i.e. in the cached content.
Signature:
cachedContentTokenCount?: number;Reference Main Generative Ai.Usagemetadata.Candidatestokencount (`docs/reference/main/generative-ai.usagemetadata.candidatestokencount.md`)
Home > @google/generative-ai > UsageMetadata > candidatesTokenCount
UsageMetadata.candidatesTokenCount property
Total number of tokens across the generated candidates.
Signature:
candidatesTokenCount: number;Reference Main Generative Ai.Usagemetadata (`docs/reference/main/generative-ai.usagemetadata.md`)
Home > @google/generative-ai > UsageMetadata
UsageMetadata interface
Metadata on the generation request's token usage.
Signature:
export interface UsageMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContentTokenCount? | number | (Optional) Total token count in the cached part of the prompt, i.e. in the cached content. | |
| candidatesTokenCount | number | Total number of tokens across the generated candidates. | |
| promptTokenCount | number | Number of tokens in the prompt. | |
| totalTokenCount | number | Total token count for the generation request (prompt + candidates). |
Reference Main Generative Ai.Usagemetadata.Prompttokencount (`docs/reference/main/generative-ai.usagemetadata.prompttokencount.md`)
Home > @google/generative-ai > UsageMetadata > promptTokenCount
UsageMetadata.promptTokenCount property
Number of tokens in the prompt.
Signature:
promptTokenCount: number;Reference Main Generative Ai.Usagemetadata.Totaltokencount (`docs/reference/main/generative-ai.usagemetadata.totaltokencount.md`)
Home > @google/generative-ai > UsageMetadata > totalTokenCount
UsageMetadata.totalTokenCount property
Total token count for the generation request (prompt + candidates).
Signature:
totalTokenCount: number;Reference Server Generative Ai.Arrayschema.Items (`docs/reference/server/generative-ai.arrayschema.items.md`)
Home > @google/generative-ai > ArraySchema > items
ArraySchema.items property
A schema describing the entries in the array.
Signature:
items: Schema;Reference Server Generative Ai.Arrayschema.Maxitems (`docs/reference/server/generative-ai.arrayschema.maxitems.md`)
Home > @google/generative-ai > ArraySchema > maxItems
ArraySchema.maxItems property
The maximum number of items in the array.
Signature:
maxItems?: number;Reference Server Generative Ai.Arrayschema (`docs/reference/server/generative-ai.arrayschema.md`)
Home > @google/generative-ai > ArraySchema
ArraySchema interface
Describes an array, an ordered list of values.
Signature:
export interface ArraySchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| items | Schema | A schema describing the entries in the array. | |
| maxItems? | number | (Optional) The maximum number of items in the array. | |
| minItems? | number | (Optional) The minimum number of items in the array. | |
| type | typeof SchemaType.ARRAY |
Reference Server Generative Ai.Arrayschema.Minitems (`docs/reference/server/generative-ai.arrayschema.minitems.md`)
Home > @google/generative-ai > ArraySchema > minItems
ArraySchema.minItems property
The minimum number of items in the array.
Signature:
minItems?: number;Reference Server Generative Ai.Arrayschema.Type (`docs/reference/server/generative-ai.arrayschema.type.md`)
Home > @google/generative-ai > ArraySchema > type
ArraySchema.type property
Signature:
type: typeof SchemaType.ARRAY;Reference Server Generative Ai.Booleanschema (`docs/reference/server/generative-ai.booleanschema.md`)
Home > @google/generative-ai > BooleanSchema
BooleanSchema interface
Describes a boolean, either 'true' or 'false'.
Signature:
export interface BooleanSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| type | typeof SchemaType.BOOLEAN |
Reference Server Generative Ai.Booleanschema.Type (`docs/reference/server/generative-ai.booleanschema.type.md`)
Home > @google/generative-ai > BooleanSchema > type
BooleanSchema.type property
Signature:
type: typeof SchemaType.BOOLEAN;Reference Server Generative Ai.Cachedcontent.Createtime (`docs/reference/server/generative-ai.cachedcontent.createtime.md`)
Home > @google/generative-ai > CachedContent > createTime
CachedContent.createTime property
CachedContent creation time in ISO string format.
Signature:
createTime?: string;Reference Server Generative Ai.Cachedcontent (`docs/reference/server/generative-ai.cachedcontent.md`)
Home > @google/generative-ai > CachedContent
CachedContent interface
Describes CachedContent interface for sending to the server (if creating) or received from the server (using getters or list methods).
Signature:
export interface CachedContent extends CachedContentBaseExtends: CachedContentBase
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| createTime? | string | (Optional) CachedContent creation time in ISO string format. |
|
| name? | string | (Optional) | |
| ttl? | string | (Optional) protobuf.Duration format (ex. "3.0001s"). | |
| updateTime? | string | (Optional) CachedContent update time in ISO string format. |
Reference Server Generative Ai.Cachedcontent.Name (`docs/reference/server/generative-ai.cachedcontent.name.md`)
Home > @google/generative-ai > CachedContent > name
CachedContent.name property
Signature:
name?: string;Reference Server Generative Ai.Cachedcontent.Ttl (`docs/reference/server/generative-ai.cachedcontent.ttl.md`)
Home > @google/generative-ai > CachedContent > ttl
CachedContent.ttl property
protobuf.Duration format (ex. "3.0001s").
Signature:
ttl?: string;Reference Server Generative Ai.Cachedcontent.Updatetime (`docs/reference/server/generative-ai.cachedcontent.updatetime.md`)
Home > @google/generative-ai > CachedContent > updateTime
CachedContent.updateTime property
CachedContent update time in ISO string format.
Signature:
updateTime?: string;Reference Server Generative Ai.Cachedcontentbase.Contents (`docs/reference/server/generative-ai.cachedcontentbase.contents.md`)
Home > @google/generative-ai > CachedContentBase > contents
CachedContentBase.contents property
Signature:
contents: Content[];Reference Server Generative Ai.Cachedcontentbase.Displayname (`docs/reference/server/generative-ai.cachedcontentbase.displayname.md`)
Home > @google/generative-ai > CachedContentBase > displayName
CachedContentBase.displayName property
Signature:
displayName?: string;Reference Server Generative Ai.Cachedcontentbase.Expiretime (`docs/reference/server/generative-ai.cachedcontentbase.expiretime.md`)
Home > @google/generative-ai > CachedContentBase > expireTime
CachedContentBase.expireTime property
Expiration time in ISO string format. Specify either this or ttlSeconds when creating a CachedContent.
Signature:
expireTime?: string;Reference Server Generative Ai.Cachedcontentbase (`docs/reference/server/generative-ai.cachedcontentbase.md`)
Home > @google/generative-ai > CachedContentBase
CachedContentBase interface
Signature:
export interface CachedContentBaseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| contents | Content[] | ||
| displayName? | string | (Optional) | |
| expireTime? | string | (Optional) Expiration time in ISO string format. Specify either this or ttlSeconds when creating a CachedContent. |
|
| model? | string | (Optional) | |
| systemInstruction? | string | Part | Content | (Optional) | |
| toolConfig? | ToolConfig | (Optional) | |
| tools? | Tool[] | (Optional) |
Reference Server Generative Ai.Cachedcontentbase.Model (`docs/reference/server/generative-ai.cachedcontentbase.model.md`)
Home > @google/generative-ai > CachedContentBase > model
CachedContentBase.model property
Signature:
model?: string;Reference Server Generative Ai.Cachedcontentbase.Systeminstruction (`docs/reference/server/generative-ai.cachedcontentbase.systeminstruction.md`)
Home > @google/generative-ai > CachedContentBase > systemInstruction
CachedContentBase.systemInstruction property
Signature:
systemInstruction?: string | Part | Content;Reference Server Generative Ai.Cachedcontentbase.Toolconfig (`docs/reference/server/generative-ai.cachedcontentbase.toolconfig.md`)
Home > @google/generative-ai > CachedContentBase > toolConfig
CachedContentBase.toolConfig property
Signature:
toolConfig?: ToolConfig;Reference Server Generative Ai.Cachedcontentbase.Tools (`docs/reference/server/generative-ai.cachedcontentbase.tools.md`)
Home > @google/generative-ai > CachedContentBase > tools
CachedContentBase.tools property
Signature:
tools?: Tool[];Reference Server Generative Ai.Cachedcontentcreateparams (`docs/reference/server/generative-ai.cachedcontentcreateparams.md`)
Home > @google/generative-ai > CachedContentCreateParams
CachedContentCreateParams interface
Params to pass to GoogleAICacheManager.create().
Signature:
export interface CachedContentCreateParams extends CachedContentBaseExtends: CachedContentBase
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| ttlSeconds? | number | (Optional) CachedContent ttl in seconds. Specify either this or expireTime when creating a CachedContent. |
Reference Server Generative Ai.Cachedcontentcreateparams.Ttlseconds (`docs/reference/server/generative-ai.cachedcontentcreateparams.ttlseconds.md`)
Home > @google/generative-ai > CachedContentCreateParams > ttlSeconds
CachedContentCreateParams.ttlSeconds property
CachedContent ttl in seconds. Specify either this or expireTime when creating a CachedContent.
Signature:
ttlSeconds?: number;Reference Server Generative Ai.Cachedcontentupdateinputfields.Expiretime (`docs/reference/server/generative-ai.cachedcontentupdateinputfields.expiretime.md`)
Home > @google/generative-ai > CachedContentUpdateInputFields > expireTime
CachedContentUpdateInputFields.expireTime property
Signature:
expireTime?: string;Reference Server Generative Ai.Cachedcontentupdateinputfields (`docs/reference/server/generative-ai.cachedcontentupdateinputfields.md`)
Home > @google/generative-ai > CachedContentUpdateInputFields
CachedContentUpdateInputFields interface
Fields that can be updated in an existing content cache.
Signature:
export interface CachedContentUpdateInputFieldsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| expireTime? | string | (Optional) | |
| ttlSeconds? | number | (Optional) |
Reference Server Generative Ai.Cachedcontentupdateinputfields.Ttlseconds (`docs/reference/server/generative-ai.cachedcontentupdateinputfields.ttlseconds.md`)
Home > @google/generative-ai > CachedContentUpdateInputFields > ttlSeconds
CachedContentUpdateInputFields.ttlSeconds property
Signature:
ttlSeconds?: number;Reference Server Generative Ai.Cachedcontentupdateparams.Cachedcontent (`docs/reference/server/generative-ai.cachedcontentupdateparams.cachedcontent.md`)
Home > @google/generative-ai > CachedContentUpdateParams > cachedContent
CachedContentUpdateParams.cachedContent property
Signature:
cachedContent: CachedContentUpdateInputFields;Reference Server Generative Ai.Cachedcontentupdateparams (`docs/reference/server/generative-ai.cachedcontentupdateparams.md`)
Home > @google/generative-ai > CachedContentUpdateParams
CachedContentUpdateParams interface
Params to pass to GoogleAICacheManager.update().
Signature:
export interface CachedContentUpdateParamsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContent | CachedContentUpdateInputFields | ||
| updateMask? | string[] | (Optional) protobuf FieldMask. If not specified, updates all provided fields. |
Reference Server Generative Ai.Cachedcontentupdateparams.Updatemask (`docs/reference/server/generative-ai.cachedcontentupdateparams.updatemask.md`)
Home > @google/generative-ai > CachedContentUpdateParams > updateMask
CachedContentUpdateParams.updateMask property
protobuf FieldMask. If not specified, updates all provided fields.
Signature:
updateMask?: string[];Reference Server Generative Ai.Codeexecutionresult (`docs/reference/server/generative-ai.codeexecutionresult.md`)
Home > @google/generative-ai > CodeExecutionResult
CodeExecutionResult interface
Result of executing the ExecutableCode. Only generated when using code execution, and always follows a Part containing the ExecutableCode.
Signature:
export interface CodeExecutionResultProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| outcome | Outcome | Outcome of the code execution. | |
| output | string | Contains stdout when code execution is successful, stderr or other description otherwise. |
Reference Server Generative Ai.Codeexecutionresult.Outcome (`docs/reference/server/generative-ai.codeexecutionresult.outcome.md`)
Home > @google/generative-ai > CodeExecutionResult > outcome
CodeExecutionResult.outcome property
Outcome of the code execution.
Signature:
outcome: Outcome;Reference Server Generative Ai.Codeexecutionresult.Output (`docs/reference/server/generative-ai.codeexecutionresult.output.md`)
Home > @google/generative-ai > CodeExecutionResult > output
CodeExecutionResult.output property
Contains stdout when code execution is successful, stderr or other description otherwise.
Signature:
output: string;Reference Server Generative Ai.Codeexecutionresultpart.Codeexecutionresult (`docs/reference/server/generative-ai.codeexecutionresultpart.codeexecutionresult.md`)
Home > @google/generative-ai > CodeExecutionResultPart > codeExecutionResult
CodeExecutionResultPart.codeExecutionResult property
Signature:
codeExecutionResult: CodeExecutionResult;Reference Server Generative Ai.Codeexecutionresultpart.Executablecode (`docs/reference/server/generative-ai.codeexecutionresultpart.executablecode.md`)
Home > @google/generative-ai > CodeExecutionResultPart > executableCode
CodeExecutionResultPart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Codeexecutionresultpart.Filedata (`docs/reference/server/generative-ai.codeexecutionresultpart.filedata.md`)
Home > @google/generative-ai > CodeExecutionResultPart > fileData
CodeExecutionResultPart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Codeexecutionresultpart.Functioncall (`docs/reference/server/generative-ai.codeexecutionresultpart.functioncall.md`)
Home > @google/generative-ai > CodeExecutionResultPart > functionCall
CodeExecutionResultPart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Codeexecutionresultpart.Functionresponse (`docs/reference/server/generative-ai.codeexecutionresultpart.functionresponse.md`)
Home > @google/generative-ai > CodeExecutionResultPart > functionResponse
CodeExecutionResultPart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Codeexecutionresultpart.Inlinedata (`docs/reference/server/generative-ai.codeexecutionresultpart.inlinedata.md`)
Home > @google/generative-ai > CodeExecutionResultPart > inlineData
CodeExecutionResultPart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Codeexecutionresultpart (`docs/reference/server/generative-ai.codeexecutionresultpart.md`)
Home > @google/generative-ai > CodeExecutionResultPart
CodeExecutionResultPart interface
Content part containing the result of executed code.
Signature:
export interface CodeExecutionResultPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult | CodeExecutionResult | ||
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Server Generative Ai.Codeexecutionresultpart.Text (`docs/reference/server/generative-ai.codeexecutionresultpart.text.md`)
Home > @google/generative-ai > CodeExecutionResultPart > text
CodeExecutionResultPart.text property
Signature:
text?: never;Reference Server Generative Ai.Codeexecutiontool.Codeexecution (`docs/reference/server/generative-ai.codeexecutiontool.codeexecution.md`)
Home > @google/generative-ai > CodeExecutionTool > codeExecution
CodeExecutionTool.codeExecution property
Provide an empty object to enable code execution. This field may have subfields added in the future.
Signature:
codeExecution: {};Reference Server Generative Ai.Codeexecutiontool (`docs/reference/server/generative-ai.codeexecutiontool.md`)
Home > @google/generative-ai > CodeExecutionTool
CodeExecutionTool interface
Enables the model to execute code as part of generation.
Signature:
export interface CodeExecutionToolProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecution | {} | Provide an empty object to enable code execution. This field may have subfields added in the future. |
Reference Server Generative Ai.Content (`docs/reference/server/generative-ai.content.md`)
Home > @google/generative-ai > Content
Content interface
Content type for both prompts and response candidates.
Signature:
export interface ContentProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| parts | Part[] | ||
| role | string |
Reference Server Generative Ai.Content.Parts (`docs/reference/server/generative-ai.content.parts.md`)
Home > @google/generative-ai > Content > parts
Content.parts property
Signature:
parts: Part[];Reference Server Generative Ai.Content.Role (`docs/reference/server/generative-ai.content.role.md`)
Home > @google/generative-ai > Content > role
Content.role property
Signature:
role: string;Reference Server Generative Ai.Enumstringschema.Enum (`docs/reference/server/generative-ai.enumstringschema.enum.md`)
Home > @google/generative-ai > EnumStringSchema > enum
EnumStringSchema.enum property
Possible values for this enum
Signature:
enum: string[];Reference Server Generative Ai.Enumstringschema.Format (`docs/reference/server/generative-ai.enumstringschema.format.md`)
Home > @google/generative-ai > EnumStringSchema > format
EnumStringSchema.format property
Signature:
format: "enum";Reference Server Generative Ai.Enumstringschema (`docs/reference/server/generative-ai.enumstringschema.md`)
Home > @google/generative-ai > EnumStringSchema
EnumStringSchema interface
Describes a string enum
Signature:
export interface EnumStringSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| enum | string[] | Possible values for this enum | |
| format | "enum" | ||
| type | typeof SchemaType.STRING |
Reference Server Generative Ai.Enumstringschema.Type (`docs/reference/server/generative-ai.enumstringschema.type.md`)
Home > @google/generative-ai > EnumStringSchema > type
EnumStringSchema.type property
Signature:
type: typeof SchemaType.STRING;Reference Server Generative Ai.Errordetails. Type (`docs/reference/server/generative-ai.errordetails.__type_.md`)
Home > @google/generative-ai > ErrorDetails > "@type"
ErrorDetails."@type" property
Signature:
"@type"?: string;Reference Server Generative Ai.Errordetails.Domain (`docs/reference/server/generative-ai.errordetails.domain.md`)
Home > @google/generative-ai > ErrorDetails > domain
ErrorDetails.domain property
Signature:
domain?: string;Reference Server Generative Ai.Errordetails (`docs/reference/server/generative-ai.errordetails.md`)
Home > @google/generative-ai > ErrorDetails
ErrorDetails interface
Details object that may be included in an error response.
Signature:
export interface ErrorDetailsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| "@type"? | string | (Optional) | |
| domain? | string | (Optional) | |
| metadata? | Record<string, unknown> | (Optional) | |
| reason? | string | (Optional) |
Reference Server Generative Ai.Errordetails.Metadata (`docs/reference/server/generative-ai.errordetails.metadata.md`)
Home > @google/generative-ai > ErrorDetails > metadata
ErrorDetails.metadata property
Signature:
metadata?: Record<string, unknown>;Reference Server Generative Ai.Errordetails.Reason (`docs/reference/server/generative-ai.errordetails.reason.md`)
Home > @google/generative-ai > ErrorDetails > reason
ErrorDetails.reason property
Signature:
reason?: string;Reference Server Generative Ai.Executablecode.Code (`docs/reference/server/generative-ai.executablecode.code.md`)
Home > @google/generative-ai > ExecutableCode > code
ExecutableCode.code property
The code to be executed.
Signature:
code: string;Reference Server Generative Ai.Executablecode.Language (`docs/reference/server/generative-ai.executablecode.language.md`)
Home > @google/generative-ai > ExecutableCode > language
ExecutableCode.language property
Programming language of the code.
Signature:
language: ExecutableCodeLanguage;Reference Server Generative Ai.Executablecode (`docs/reference/server/generative-ai.executablecode.md`)
Home > @google/generative-ai > ExecutableCode
ExecutableCode interface
Code generated by the model that is meant to be executed, where the result is returned to the model. Only generated when using the code execution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
Signature:
export interface ExecutableCodeProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| code | string | The code to be executed. | |
| language | ExecutableCodeLanguage | Programming language of the code. |
Reference Server Generative Ai.Executablecodelanguage (`docs/reference/server/generative-ai.executablecodelanguage.md`)
Home > @google/generative-ai > ExecutableCodeLanguage
ExecutableCodeLanguage enum
Signature:
export declare enum ExecutableCodeLanguageEnumeration Members
| Member | Value | Description |
|---|---|---|
| LANGUAGE_UNSPECIFIED | "language_unspecified" |
|
| PYTHON | "python" |
Reference Server Generative Ai.Executablecodepart.Codeexecutionresult (`docs/reference/server/generative-ai.executablecodepart.codeexecutionresult.md`)
Home > @google/generative-ai > ExecutableCodePart > codeExecutionResult
ExecutableCodePart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Executablecodepart.Executablecode (`docs/reference/server/generative-ai.executablecodepart.executablecode.md`)
Home > @google/generative-ai > ExecutableCodePart > executableCode
ExecutableCodePart.executableCode property
Signature:
executableCode: ExecutableCode;Reference Server Generative Ai.Executablecodepart.Filedata (`docs/reference/server/generative-ai.executablecodepart.filedata.md`)
Home > @google/generative-ai > ExecutableCodePart > fileData
ExecutableCodePart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Executablecodepart.Functioncall (`docs/reference/server/generative-ai.executablecodepart.functioncall.md`)
Home > @google/generative-ai > ExecutableCodePart > functionCall
ExecutableCodePart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Executablecodepart.Functionresponse (`docs/reference/server/generative-ai.executablecodepart.functionresponse.md`)
Home > @google/generative-ai > ExecutableCodePart > functionResponse
ExecutableCodePart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Executablecodepart.Inlinedata (`docs/reference/server/generative-ai.executablecodepart.inlinedata.md`)
Home > @google/generative-ai > ExecutableCodePart > inlineData
ExecutableCodePart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Executablecodepart (`docs/reference/server/generative-ai.executablecodepart.md`)
Home > @google/generative-ai > ExecutableCodePart
ExecutableCodePart interface
Content part containing executable code generated by the model.
Signature:
export interface ExecutableCodePartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode | ExecutableCode | ||
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Server Generative Ai.Executablecodepart.Text (`docs/reference/server/generative-ai.executablecodepart.text.md`)
Home > @google/generative-ai > ExecutableCodePart > text
ExecutableCodePart.text property
Signature:
text?: never;Reference Server Generative Ai.Filedata.Fileuri (`docs/reference/server/generative-ai.filedata.fileuri.md`)
Home > @google/generative-ai > FileData > fileUri
FileData.fileUri property
Signature:
fileUri: string;Reference Server Generative Ai.Filedata (`docs/reference/server/generative-ai.filedata.md`)
Home > @google/generative-ai > FileData
FileData interface
Data pointing to a file uploaded with the Files API.
Signature:
export interface FileDataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| fileUri | string | ||
| mimeType | string |
Reference Server Generative Ai.Filedata.Mimetype (`docs/reference/server/generative-ai.filedata.mimetype.md`)
Home > @google/generative-ai > FileData > mimeType
FileData.mimeType property
Signature:
mimeType: string;Reference Server Generative Ai.Filedatapart.Codeexecutionresult (`docs/reference/server/generative-ai.filedatapart.codeexecutionresult.md`)
Home > @google/generative-ai > FileDataPart > codeExecutionResult
FileDataPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Filedatapart.Executablecode (`docs/reference/server/generative-ai.filedatapart.executablecode.md`)
Home > @google/generative-ai > FileDataPart > executableCode
FileDataPart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Filedatapart.Filedata (`docs/reference/server/generative-ai.filedatapart.filedata.md`)
Home > @google/generative-ai > FileDataPart > fileData
FileDataPart.fileData property
Signature:
fileData: FileData;Reference Server Generative Ai.Filedatapart.Functioncall (`docs/reference/server/generative-ai.filedatapart.functioncall.md`)
Home > @google/generative-ai > FileDataPart > functionCall
FileDataPart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Filedatapart.Functionresponse (`docs/reference/server/generative-ai.filedatapart.functionresponse.md`)
Home > @google/generative-ai > FileDataPart > functionResponse
FileDataPart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Filedatapart.Inlinedata (`docs/reference/server/generative-ai.filedatapart.inlinedata.md`)
Home > @google/generative-ai > FileDataPart > inlineData
FileDataPart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Filedatapart (`docs/reference/server/generative-ai.filedatapart.md`)
Home > @google/generative-ai > FileDataPart
FileDataPart interface
Content part interface if the part represents FileData.
Signature:
export interface FileDataPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData | FileData | ||
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Server Generative Ai.Filedatapart.Text (`docs/reference/server/generative-ai.filedatapart.text.md`)
Home > @google/generative-ai > FileDataPart > text
FileDataPart.text property
Signature:
text?: never;Reference Server Generative Ai.Filemetadata.Displayname (`docs/reference/server/generative-ai.filemetadata.displayname.md`)
Home > @google/generative-ai > FileMetadata > displayName
FileMetadata.displayName property
Signature:
displayName?: string;Reference Server Generative Ai.Filemetadata (`docs/reference/server/generative-ai.filemetadata.md`)
Home > @google/generative-ai > FileMetadata
FileMetadata interface
Metadata to provide alongside a file upload
Signature:
export interface FileMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| displayName? | string | (Optional) | |
| mimeType | string | ||
| name? | string | (Optional) |
Reference Server Generative Ai.Filemetadata.Mimetype (`docs/reference/server/generative-ai.filemetadata.mimetype.md`)
Home > @google/generative-ai > FileMetadata > mimeType
FileMetadata.mimeType property
Signature:
mimeType: string;Reference Server Generative Ai.Filemetadata.Name (`docs/reference/server/generative-ai.filemetadata.name.md`)
Home > @google/generative-ai > FileMetadata > name
FileMetadata.name property
Signature:
name?: string;Reference Server Generative Ai.Filemetadataresponse.Createtime (`docs/reference/server/generative-ai.filemetadataresponse.createtime.md`)
Home > @google/generative-ai > FileMetadataResponse > createTime
FileMetadataResponse.createTime property
Signature:
createTime: string;Reference Server Generative Ai.Filemetadataresponse.Displayname (`docs/reference/server/generative-ai.filemetadataresponse.displayname.md`)
Home > @google/generative-ai > FileMetadataResponse > displayName
FileMetadataResponse.displayName property
Signature:
displayName?: string;Reference Server Generative Ai.Filemetadataresponse.Error (`docs/reference/server/generative-ai.filemetadataresponse.error.md`)
Home > @google/generative-ai > FileMetadataResponse > error
FileMetadataResponse.error property
Error populated if file processing has failed.
Signature:
error?: RpcStatus;Reference Server Generative Ai.Filemetadataresponse.Expirationtime (`docs/reference/server/generative-ai.filemetadataresponse.expirationtime.md`)
Home > @google/generative-ai > FileMetadataResponse > expirationTime
FileMetadataResponse.expirationTime property
Signature:
expirationTime: string;Reference Server Generative Ai.Filemetadataresponse (`docs/reference/server/generative-ai.filemetadataresponse.md`)
Home > @google/generative-ai > FileMetadataResponse
FileMetadataResponse interface
File metadata response from server.
Signature:
export interface FileMetadataResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| createTime | string | ||
| displayName? | string | (Optional) | |
| error? | RpcStatus | (Optional) Error populated if file processing has failed. | |
| expirationTime | string | ||
| mimeType | string | ||
| name | string | ||
| sha256Hash | string | ||
| sizeBytes | string | ||
| state | FileState | ||
| updateTime | string | ||
| uri | string | ||
| videoMetadata? | VideoMetadata | (Optional) Video metadata populated after processing is complete. |
Reference Server Generative Ai.Filemetadataresponse.Mimetype (`docs/reference/server/generative-ai.filemetadataresponse.mimetype.md`)
Home > @google/generative-ai > FileMetadataResponse > mimeType
FileMetadataResponse.mimeType property
Signature:
mimeType: string;Reference Server Generative Ai.Filemetadataresponse.Name (`docs/reference/server/generative-ai.filemetadataresponse.name.md`)
Home > @google/generative-ai > FileMetadataResponse > name
FileMetadataResponse.name property
Signature:
name: string;Reference Server Generative Ai.Filemetadataresponse.Sha256hash (`docs/reference/server/generative-ai.filemetadataresponse.sha256hash.md`)
Home > @google/generative-ai > FileMetadataResponse > sha256Hash
FileMetadataResponse.sha256Hash property
Signature:
sha256Hash: string;Reference Server Generative Ai.Filemetadataresponse.Sizebytes (`docs/reference/server/generative-ai.filemetadataresponse.sizebytes.md`)
Home > @google/generative-ai > FileMetadataResponse > sizeBytes
FileMetadataResponse.sizeBytes property
Signature:
sizeBytes: string;Reference Server Generative Ai.Filemetadataresponse.State (`docs/reference/server/generative-ai.filemetadataresponse.state.md`)
Home > @google/generative-ai > FileMetadataResponse > state
FileMetadataResponse.state property
Signature:
state: FileState;Reference Server Generative Ai.Filemetadataresponse.Updatetime (`docs/reference/server/generative-ai.filemetadataresponse.updatetime.md`)
Home > @google/generative-ai > FileMetadataResponse > updateTime
FileMetadataResponse.updateTime property
Signature:
updateTime: string;Reference Server Generative Ai.Filemetadataresponse.Uri (`docs/reference/server/generative-ai.filemetadataresponse.uri.md`)
Home > @google/generative-ai > FileMetadataResponse > uri
FileMetadataResponse.uri property
Signature:
uri: string;Reference Server Generative Ai.Filemetadataresponse.Videometadata (`docs/reference/server/generative-ai.filemetadataresponse.videometadata.md`)
Home > @google/generative-ai > FileMetadataResponse > videoMetadata
FileMetadataResponse.videoMetadata property
Video metadata populated after processing is complete.
Signature:
videoMetadata?: VideoMetadata;Reference Server Generative Ai.Filestate (`docs/reference/server/generative-ai.filestate.md`)
Home > @google/generative-ai > FileState
FileState enum
Processing state of the File.
Signature:
export declare enum FileStateEnumeration Members
| Member | Value | Description |
|---|---|---|
| ACTIVE | "ACTIVE" |
|
| FAILED | "FAILED" |
|
| PROCESSING | "PROCESSING" |
|
| STATE_UNSPECIFIED | "STATE_UNSPECIFIED" |
Reference Server Generative Ai.Functioncall.Args (`docs/reference/server/generative-ai.functioncall.args.md`)
Home > @google/generative-ai > FunctionCall > args
FunctionCall.args property
Signature:
args: object;Reference Server Generative Ai.Functioncall (`docs/reference/server/generative-ai.functioncall.md`)
Home > @google/generative-ai > FunctionCall
FunctionCall interface
A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing the parameters and their values.
Signature:
export interface FunctionCallProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| args | object | ||
| name | string |
Reference Server Generative Ai.Functioncall.Name (`docs/reference/server/generative-ai.functioncall.name.md`)
Home > @google/generative-ai > FunctionCall > name
FunctionCall.name property
Signature:
name: string;Reference Server Generative Ai.Functioncallingconfig.Allowedfunctionnames (`docs/reference/server/generative-ai.functioncallingconfig.allowedfunctionnames.md`)
Home > @google/generative-ai > FunctionCallingConfig > allowedFunctionNames
FunctionCallingConfig.allowedFunctionNames property
Signature:
allowedFunctionNames?: string[];Reference Server Generative Ai.Functioncallingconfig (`docs/reference/server/generative-ai.functioncallingconfig.md`)
Home > @google/generative-ai > FunctionCallingConfig
FunctionCallingConfig interface
Signature:
export interface FunctionCallingConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| allowedFunctionNames? | string[] | (Optional) | |
| mode? | FunctionCallingMode | (Optional) |
Reference Server Generative Ai.Functioncallingconfig.Mode (`docs/reference/server/generative-ai.functioncallingconfig.mode.md`)
Home > @google/generative-ai > FunctionCallingConfig > mode
FunctionCallingConfig.mode property
Signature:
mode?: FunctionCallingMode;Reference Server Generative Ai.Functioncallingmode (`docs/reference/server/generative-ai.functioncallingmode.md`)
Home > @google/generative-ai > FunctionCallingMode
FunctionCallingMode enum
Signature:
export declare enum FunctionCallingModeEnumeration Members
| Member | Value | Description |
|---|---|---|
| ANY | "ANY" |
|
| AUTO | "AUTO" |
|
| MODE_UNSPECIFIED | "MODE_UNSPECIFIED" |
|
| NONE | "NONE" |
Reference Server Generative Ai.Functioncallpart.Codeexecutionresult (`docs/reference/server/generative-ai.functioncallpart.codeexecutionresult.md`)
Home > @google/generative-ai > FunctionCallPart > codeExecutionResult
FunctionCallPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Functioncallpart.Executablecode (`docs/reference/server/generative-ai.functioncallpart.executablecode.md`)
Home > @google/generative-ai > FunctionCallPart > executableCode
FunctionCallPart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Functioncallpart.Filedata (`docs/reference/server/generative-ai.functioncallpart.filedata.md`)
Home > @google/generative-ai > FunctionCallPart > fileData
FunctionCallPart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Functioncallpart.Functioncall (`docs/reference/server/generative-ai.functioncallpart.functioncall.md`)
Home > @google/generative-ai > FunctionCallPart > functionCall
FunctionCallPart.functionCall property
Signature:
functionCall: FunctionCall;Reference Server Generative Ai.Functioncallpart.Functionresponse (`docs/reference/server/generative-ai.functioncallpart.functionresponse.md`)
Home > @google/generative-ai > FunctionCallPart > functionResponse
FunctionCallPart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Functioncallpart.Inlinedata (`docs/reference/server/generative-ai.functioncallpart.inlinedata.md`)
Home > @google/generative-ai > FunctionCallPart > inlineData
FunctionCallPart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Functioncallpart (`docs/reference/server/generative-ai.functioncallpart.md`)
Home > @google/generative-ai > FunctionCallPart
FunctionCallPart interface
Content part interface if the part represents a FunctionCall.
Signature:
export interface FunctionCallPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall | FunctionCall | ||
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Server Generative Ai.Functioncallpart.Text (`docs/reference/server/generative-ai.functioncallpart.text.md`)
Home > @google/generative-ai > FunctionCallPart > text
FunctionCallPart.text property
Signature:
text?: never;Reference Server Generative Ai.Functiondeclaration.Description (`docs/reference/server/generative-ai.functiondeclaration.description.md`)
Home > @google/generative-ai > FunctionDeclaration > description
FunctionDeclaration.description property
Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function.
Signature:
description?: string;Reference Server Generative Ai.Functiondeclaration (`docs/reference/server/generative-ai.functiondeclaration.md`)
Home > @google/generative-ai > FunctionDeclaration
FunctionDeclaration interface
Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client.
Signature:
export declare interface FunctionDeclarationProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| description? | string | (Optional) Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. | |
| name | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | |
| parameters? | FunctionDeclarationSchema | (Optional) Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset. |
Reference Server Generative Ai.Functiondeclaration.Name (`docs/reference/server/generative-ai.functiondeclaration.name.md`)
Home > @google/generative-ai > FunctionDeclaration > name
FunctionDeclaration.name property
The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64.
Signature:
name: string;Reference Server Generative Ai.Functiondeclaration.Parameters (`docs/reference/server/generative-ai.functiondeclaration.parameters.md`)
Home > @google/generative-ai > FunctionDeclaration > parameters
FunctionDeclaration.parameters property
Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. string Key: the name of the parameter. Parameter names are case sensitive. Schema Value: the Schema defining the type used for the parameter. For function with no parameters, this can be left unset.
Signature:
parameters?: FunctionDeclarationSchema;Example
with 1 required and 1 optional parameter: type: OBJECT properties:
param1:
type: STRING
param2:
type: INTEGER
required:
- param1Reference Server Generative Ai.Functiondeclarationschema.Description (`docs/reference/server/generative-ai.functiondeclarationschema.description.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > description
FunctionDeclarationSchema.description property
Optional. Description of the parameter.
Signature:
description?: string;Reference Server Generative Ai.Functiondeclarationschema (`docs/reference/server/generative-ai.functiondeclarationschema.md`)
Home > @google/generative-ai > FunctionDeclarationSchema
FunctionDeclarationSchema interface
Schema for parameters passed to FunctionDeclaration.parameters.
Signature:
export interface FunctionDeclarationSchemaProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| description? | string | (Optional) Optional. Description of the parameter. | |
| properties | { [k: string]: FunctionDeclarationSchemaProperty; } | The format of the parameter. | |
| required? | string[] | (Optional) Optional. Array of required parameters. | |
| type | SchemaType | The type of the parameter. |
Reference Server Generative Ai.Functiondeclarationschema.Properties (`docs/reference/server/generative-ai.functiondeclarationschema.properties.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > properties
FunctionDeclarationSchema.properties property
The format of the parameter.
Signature:
properties: {
[k: string]: FunctionDeclarationSchemaProperty;
};Reference Server Generative Ai.Functiondeclarationschema.Required (`docs/reference/server/generative-ai.functiondeclarationschema.required.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > required
FunctionDeclarationSchema.required property
Optional. Array of required parameters.
Signature:
required?: string[];Reference Server Generative Ai.Functiondeclarationschema.Type (`docs/reference/server/generative-ai.functiondeclarationschema.type.md`)
Home > @google/generative-ai > FunctionDeclarationSchema > type
FunctionDeclarationSchema.type property
The type of the parameter.
Signature:
type: SchemaType;Reference Server Generative Ai.Functiondeclarationschemaproperty (`docs/reference/server/generative-ai.functiondeclarationschemaproperty.md`)
Home > @google/generative-ai > FunctionDeclarationSchemaProperty
FunctionDeclarationSchemaProperty type
Schema for top-level function declaration
Signature:
export type FunctionDeclarationSchemaProperty = Schema;References: Schema
Reference Server Generative Ai.Functiondeclarationstool.Functiondeclarations (`docs/reference/server/generative-ai.functiondeclarationstool.functiondeclarations.md`)
Home > @google/generative-ai > FunctionDeclarationsTool > functionDeclarations
FunctionDeclarationsTool.functionDeclarations property
Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall][content.part.functionCall] in the response. User should provide a [FunctionResponse][content.part.functionResponse] for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 64 function declarations can be provided.
Signature:
functionDeclarations?: FunctionDeclaration[];Reference Server Generative Ai.Functiondeclarationstool (`docs/reference/server/generative-ai.functiondeclarationstool.md`)
Home > @google/generative-ai > FunctionDeclarationsTool
FunctionDeclarationsTool interface
A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model.
Signature:
export declare interface FunctionDeclarationsToolProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| functionDeclarations? | FunctionDeclaration[] | (Optional) Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall][content.part.functionCall] in the response. User should provide a [FunctionResponse][content.part.functionResponse] for each function call in the next turn. Based on the function responses, Model will generate the final response back to the user. Maximum 64 function declarations can be provided. |
Reference Server Generative Ai.Functionresponse (`docs/reference/server/generative-ai.functionresponse.md`)
Home > @google/generative-ai > FunctionResponse
FunctionResponse interface
The result output from a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall] made based on model prediction.
Signature:
export interface FunctionResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| name | string | ||
| response | object |
Reference Server Generative Ai.Functionresponse.Name (`docs/reference/server/generative-ai.functionresponse.name.md`)
Home > @google/generative-ai > FunctionResponse > name
FunctionResponse.name property
Signature:
name: string;Reference Server Generative Ai.Functionresponse.Response (`docs/reference/server/generative-ai.functionresponse.response.md`)
Home > @google/generative-ai > FunctionResponse > response
FunctionResponse.response property
Signature:
response: object;Reference Server Generative Ai.Functionresponsepart.Codeexecutionresult (`docs/reference/server/generative-ai.functionresponsepart.codeexecutionresult.md`)
Home > @google/generative-ai > FunctionResponsePart > codeExecutionResult
FunctionResponsePart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Functionresponsepart.Executablecode (`docs/reference/server/generative-ai.functionresponsepart.executablecode.md`)
Home > @google/generative-ai > FunctionResponsePart > executableCode
FunctionResponsePart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Functionresponsepart.Filedata (`docs/reference/server/generative-ai.functionresponsepart.filedata.md`)
Home > @google/generative-ai > FunctionResponsePart > fileData
FunctionResponsePart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Functionresponsepart.Functioncall (`docs/reference/server/generative-ai.functionresponsepart.functioncall.md`)
Home > @google/generative-ai > FunctionResponsePart > functionCall
FunctionResponsePart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Functionresponsepart.Functionresponse (`docs/reference/server/generative-ai.functionresponsepart.functionresponse.md`)
Home > @google/generative-ai > FunctionResponsePart > functionResponse
FunctionResponsePart.functionResponse property
Signature:
functionResponse: FunctionResponse;Reference Server Generative Ai.Functionresponsepart.Inlinedata (`docs/reference/server/generative-ai.functionresponsepart.inlinedata.md`)
Home > @google/generative-ai > FunctionResponsePart > inlineData
FunctionResponsePart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Functionresponsepart (`docs/reference/server/generative-ai.functionresponsepart.md`)
Home > @google/generative-ai > FunctionResponsePart
FunctionResponsePart interface
Content part interface if the part represents FunctionResponse.
Signature:
export interface FunctionResponsePartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse | FunctionResponse | ||
| inlineData? | never | (Optional) | |
| text? | never | (Optional) |
Reference Server Generative Ai.Functionresponsepart.Text (`docs/reference/server/generative-ai.functionresponsepart.text.md`)
Home > @google/generative-ai > FunctionResponsePart > text
FunctionResponsePart.text property
Signature:
text?: never;Reference Server Generative Ai.Generativecontentblob.Data (`docs/reference/server/generative-ai.generativecontentblob.data.md`)
Home > @google/generative-ai > GenerativeContentBlob > data
GenerativeContentBlob.data property
Image as a base64 string.
Signature:
data: string;Reference Server Generative Ai.Generativecontentblob (`docs/reference/server/generative-ai.generativecontentblob.md`)
Home > @google/generative-ai > GenerativeContentBlob
GenerativeContentBlob interface
Interface for sending an image.
Signature:
export interface GenerativeContentBlobProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| data | string | Image as a base64 string. | |
| mimeType | string |
Reference Server Generative Ai.Generativecontentblob.Mimetype (`docs/reference/server/generative-ai.generativecontentblob.mimetype.md`)
Home > @google/generative-ai > GenerativeContentBlob > mimeType
GenerativeContentBlob.mimeType property
Signature:
mimeType: string;Reference Server Generative Ai.Googleaicachemanager. Constructor (`docs/reference/server/generative-ai.googleaicachemanager._constructor_.md`)
Home > @google/generative-ai > GoogleAICacheManager > (constructor)
GoogleAICacheManager.(constructor)
Constructs a new instance of the GoogleAICacheManager class
Signature:
constructor(apiKey: string, _requestOptions?: RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string | |
| _requestOptions | RequestOptions | (Optional) |
Reference Server Generative Ai.Googleaicachemanager.Apikey (`docs/reference/server/generative-ai.googleaicachemanager.apikey.md`)
Home > @google/generative-ai > GoogleAICacheManager > apiKey
GoogleAICacheManager.apiKey property
Signature:
apiKey: string;Reference Server Generative Ai.Googleaicachemanager.Create (`docs/reference/server/generative-ai.googleaicachemanager.create.md`)
Home > @google/generative-ai > GoogleAICacheManager > create
GoogleAICacheManager.create() method
Upload a new content cache
Signature:
create(createOptions: CachedContentCreateParams): Promise<CachedContent>;Parameters
| Parameter | Type | Description |
|---|---|---|
| createOptions | CachedContentCreateParams |
Returns:
Promise<CachedContent>
Reference Server Generative Ai.Googleaicachemanager.Delete (`docs/reference/server/generative-ai.googleaicachemanager.delete.md`)
Home > @google/generative-ai > GoogleAICacheManager > delete
GoogleAICacheManager.delete() method
Delete content cache with given name
Signature:
delete(name: string): Promise<void>;Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string |
Returns:
Promise<void>
Reference Server Generative Ai.Googleaicachemanager.Get (`docs/reference/server/generative-ai.googleaicachemanager.get.md`)
Home > @google/generative-ai > GoogleAICacheManager > get
GoogleAICacheManager.get() method
Get a content cache
Signature:
get(name: string): Promise<CachedContent>;Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string |
Returns:
Promise<CachedContent>
Reference Server Generative Ai.Googleaicachemanager.List (`docs/reference/server/generative-ai.googleaicachemanager.list.md`)
Home > @google/generative-ai > GoogleAICacheManager > list
GoogleAICacheManager.list() method
List all uploaded content caches
Signature:
list(listParams?: ListParams): Promise<ListCacheResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| listParams | ListParams | (Optional) |
Returns:
Promise<ListCacheResponse>
Reference Server Generative Ai.Googleaicachemanager (`docs/reference/server/generative-ai.googleaicachemanager.md`)
Home > @google/generative-ai > GoogleAICacheManager
GoogleAICacheManager class
Class for managing GoogleAI content caches.
Signature:
export declare class GoogleAICacheManagerConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, _requestOptions) | Constructs a new instance of the GoogleAICacheManager class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiKey | string |
Methods
| Method | Modifiers | Description |
|---|---|---|
| create(createOptions) | Upload a new content cache | |
| delete(name) | Delete content cache with given name | |
| get(name) | Get a content cache | |
| list(listParams) | List all uploaded content caches | |
| update(name, updateParams) | Update an existing content cache |
Reference Server Generative Ai.Googleaicachemanager.Update (`docs/reference/server/generative-ai.googleaicachemanager.update.md`)
Home > @google/generative-ai > GoogleAICacheManager > update
GoogleAICacheManager.update() method
Update an existing content cache
Signature:
update(name: string, updateParams: CachedContentUpdateParams): Promise<CachedContent>;Parameters
| Parameter | Type | Description |
|---|---|---|
| name | string | |
| updateParams | CachedContentUpdateParams |
Returns:
Promise<CachedContent>
Reference Server Generative Ai.Googleaifilemanager. Constructor (`docs/reference/server/generative-ai.googleaifilemanager._constructor_.md`)
Home > @google/generative-ai > GoogleAIFileManager > (constructor)
GoogleAIFileManager.(constructor)
Constructs a new instance of the GoogleAIFileManager class
Signature:
constructor(apiKey: string, _requestOptions?: RequestOptions);Parameters
| Parameter | Type | Description |
|---|---|---|
| apiKey | string | |
| _requestOptions | RequestOptions | (Optional) |
Reference Server Generative Ai.Googleaifilemanager.Apikey (`docs/reference/server/generative-ai.googleaifilemanager.apikey.md`)
Home > @google/generative-ai > GoogleAIFileManager > apiKey
GoogleAIFileManager.apiKey property
Signature:
apiKey: string;Reference Server Generative Ai.Googleaifilemanager.Deletefile (`docs/reference/server/generative-ai.googleaifilemanager.deletefile.md`)
Home > @google/generative-ai > GoogleAIFileManager > deleteFile
GoogleAIFileManager.deleteFile() method
Delete file with given ID.
Signature:
deleteFile(fileId: string): Promise<void>;Parameters
| Parameter | Type | Description |
|---|---|---|
| fileId | string |
Returns:
Promise<void>
Reference Server Generative Ai.Googleaifilemanager.Getfile (`docs/reference/server/generative-ai.googleaifilemanager.getfile.md`)
Home > @google/generative-ai > GoogleAIFileManager > getFile
GoogleAIFileManager.getFile() method
Get metadata for file with given ID.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
getFile(fileId: string, requestOptions?: SingleRequestOptions): Promise<FileMetadataResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| fileId | string | |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<FileMetadataResponse>
Reference Server Generative Ai.Googleaifilemanager.Listfiles (`docs/reference/server/generative-ai.googleaifilemanager.listfiles.md`)
Home > @google/generative-ai > GoogleAIFileManager > listFiles
GoogleAIFileManager.listFiles() method
List all uploaded files.
Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization.
Signature:
listFiles(listParams?: ListParams, requestOptions?: SingleRequestOptions): Promise<ListFilesResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| listParams | ListParams | (Optional) |
| requestOptions | SingleRequestOptions | (Optional) |
Returns:
Promise<ListFilesResponse>
Reference Server Generative Ai.Googleaifilemanager (`docs/reference/server/generative-ai.googleaifilemanager.md`)
Home > @google/generative-ai > GoogleAIFileManager
GoogleAIFileManager class
Class for managing GoogleAI file uploads.
Signature:
export declare class GoogleAIFileManagerConstructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(apiKey, _requestOptions) | Constructs a new instance of the GoogleAIFileManager class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiKey | string |
Methods
| Method | Modifiers | Description |
|---|---|---|
| deleteFile(fileId) | Delete file with given ID. | |
| getFile(fileId, requestOptions) | Get metadata for file with given ID.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. | |
| listFiles(listParams, requestOptions) | List all uploaded files.Any fields set in the optional SingleRequestOptions parameter will take precedence over the RequestOptions values provided at the time of the GoogleAIFileManager initialization. | |
| uploadFile(fileData, fileMetadata) | Upload a file. |
Reference Server Generative Ai.Googleaifilemanager.Uploadfile (`docs/reference/server/generative-ai.googleaifilemanager.uploadfile.md`)
Home > @google/generative-ai > GoogleAIFileManager > uploadFile
GoogleAIFileManager.uploadFile() method
Upload a file.
Signature:
uploadFile(fileData: string | Buffer, fileMetadata: FileMetadata): Promise<UploadFileResponse>;Parameters
| Parameter | Type | Description |
|---|---|---|
| fileData | string | Buffer | |
| fileMetadata | FileMetadata |
Returns:
Promise<UploadFileResponse>
Reference Server Generative Ai.Inlinedatapart.Codeexecutionresult (`docs/reference/server/generative-ai.inlinedatapart.codeexecutionresult.md`)
Home > @google/generative-ai > InlineDataPart > codeExecutionResult
InlineDataPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Inlinedatapart.Executablecode (`docs/reference/server/generative-ai.inlinedatapart.executablecode.md`)
Home > @google/generative-ai > InlineDataPart > executableCode
InlineDataPart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Inlinedatapart.Filedata (`docs/reference/server/generative-ai.inlinedatapart.filedata.md`)
Home > @google/generative-ai > InlineDataPart > fileData
InlineDataPart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Inlinedatapart.Functioncall (`docs/reference/server/generative-ai.inlinedatapart.functioncall.md`)
Home > @google/generative-ai > InlineDataPart > functionCall
InlineDataPart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Inlinedatapart.Functionresponse (`docs/reference/server/generative-ai.inlinedatapart.functionresponse.md`)
Home > @google/generative-ai > InlineDataPart > functionResponse
InlineDataPart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Inlinedatapart.Inlinedata (`docs/reference/server/generative-ai.inlinedatapart.inlinedata.md`)
Home > @google/generative-ai > InlineDataPart > inlineData
InlineDataPart.inlineData property
Signature:
inlineData: GenerativeContentBlob;Reference Server Generative Ai.Inlinedatapart (`docs/reference/server/generative-ai.inlinedatapart.md`)
Home > @google/generative-ai > InlineDataPart
InlineDataPart interface
Content part interface if the part represents an image.
Signature:
export interface InlineDataPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData | GenerativeContentBlob | ||
| text? | never | (Optional) |
Reference Server Generative Ai.Inlinedatapart.Text (`docs/reference/server/generative-ai.inlinedatapart.text.md`)
Home > @google/generative-ai > InlineDataPart > text
InlineDataPart.text property
Signature:
text?: never;Reference Server Generative Ai.Integerschema.Format (`docs/reference/server/generative-ai.integerschema.format.md`)
Home > @google/generative-ai > IntegerSchema > format
IntegerSchema.format property
Optional. The format of the number.
Signature:
format?: "int32" | "int64";Reference Server Generative Ai.Integerschema (`docs/reference/server/generative-ai.integerschema.md`)
Home > @google/generative-ai > IntegerSchema
IntegerSchema interface
Describes a JSON-encodable integer.
Signature:
export interface IntegerSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| format? | "int32" | "int64" | (Optional) Optional. The format of the number. | |
| type | typeof SchemaType.INTEGER |
Reference Server Generative Ai.Integerschema.Type (`docs/reference/server/generative-ai.integerschema.type.md`)
Home > @google/generative-ai > IntegerSchema > type
IntegerSchema.type property
Signature:
type: typeof SchemaType.INTEGER;Reference Server Generative Ai.Listcacheresponse.Cachedcontents (`docs/reference/server/generative-ai.listcacheresponse.cachedcontents.md`)
Home > @google/generative-ai > ListCacheResponse > cachedContents
ListCacheResponse.cachedContents property
Signature:
cachedContents: CachedContent[];Reference Server Generative Ai.Listcacheresponse (`docs/reference/server/generative-ai.listcacheresponse.md`)
Home > @google/generative-ai > ListCacheResponse
ListCacheResponse interface
Signature:
export interface ListCacheResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| cachedContents | CachedContent[] | ||
| nextPageToken? | string | (Optional) |
Reference Server Generative Ai.Listcacheresponse.Nextpagetoken (`docs/reference/server/generative-ai.listcacheresponse.nextpagetoken.md`)
Home > @google/generative-ai > ListCacheResponse > nextPageToken
ListCacheResponse.nextPageToken property
Signature:
nextPageToken?: string;Reference Server Generative Ai.Listfilesresponse.Files (`docs/reference/server/generative-ai.listfilesresponse.files.md`)
Home > @google/generative-ai > ListFilesResponse > files
ListFilesResponse.files property
Signature:
files: FileMetadataResponse[];Reference Server Generative Ai.Listfilesresponse (`docs/reference/server/generative-ai.listfilesresponse.md`)
Home > @google/generative-ai > ListFilesResponse
ListFilesResponse interface
Response from calling GoogleAIFileManager.listFiles()
Signature:
export interface ListFilesResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| files | FileMetadataResponse[] | ||
| nextPageToken? | string | (Optional) |
Reference Server Generative Ai.Listfilesresponse.Nextpagetoken (`docs/reference/server/generative-ai.listfilesresponse.nextpagetoken.md`)
Home > @google/generative-ai > ListFilesResponse > nextPageToken
ListFilesResponse.nextPageToken property
Signature:
nextPageToken?: string;Reference Server Generative Ai.Listparams (`docs/reference/server/generative-ai.listparams.md`)
Home > @google/generative-ai > ListParams
ListParams interface
Params to pass to GoogleAIFileManager.listFiles() or GoogleAICacheManager.list()
Signature:
export interface ListParamsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| pageSize? | number | (Optional) | |
| pageToken? | string | (Optional) |
Reference Server Generative Ai.Listparams.Pagesize (`docs/reference/server/generative-ai.listparams.pagesize.md`)
Home > @google/generative-ai > ListParams > pageSize
ListParams.pageSize property
Signature:
pageSize?: number;Reference Server Generative Ai.Listparams.Pagetoken (`docs/reference/server/generative-ai.listparams.pagetoken.md`)
Home > @google/generative-ai > ListParams > pageToken
ListParams.pageToken property
Signature:
pageToken?: string;Reference Server Generative Ai (`docs/reference/server/generative-ai.md`)
generative-ai package
Classes
| Class | Description |
|---|---|
| GoogleAICacheManager | Class for managing GoogleAI content caches. |
| GoogleAIFileManager | Class for managing GoogleAI file uploads. |
Enumerations
| Enumeration | Description |
|---|---|
| ExecutableCodeLanguage | |
| FileState | Processing state of the File. |
| FunctionCallingMode | |
| Outcome | Possible outcomes of code execution. |
| SchemaType | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ |
Interfaces
| Interface | Description |
|---|---|
| ArraySchema | Describes an array, an ordered list of values. |
| BooleanSchema | Describes a boolean, either 'true' or 'false'. |
| CachedContent | Describes CachedContent interface for sending to the server (if creating) or received from the server (using getters or list methods). |
| CachedContentBase | |
| CachedContentCreateParams | Params to pass to GoogleAICacheManager.create(). |
| CachedContentUpdateInputFields | Fields that can be updated in an existing content cache. |
| CachedContentUpdateParams | Params to pass to GoogleAICacheManager.update(). |
| CodeExecutionResult | Result of executing the ExecutableCode. Only generated when using code execution, and always follows a Part containing the ExecutableCode. |
| CodeExecutionResultPart | Content part containing the result of executed code. |
| CodeExecutionTool | Enables the model to execute code as part of generation. |
| Content | Content type for both prompts and response candidates. |
| EnumStringSchema | Describes a string enum |
| ErrorDetails | Details object that may be included in an error response. |
| ExecutableCode | Code generated by the model that is meant to be executed, where the result is returned to the model. Only generated when using the code execution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated. |
| ExecutableCodePart | Content part containing executable code generated by the model. |
| FileData | Data pointing to a file uploaded with the Files API. |
| FileDataPart | Content part interface if the part represents FileData. |
| FileMetadata | Metadata to provide alongside a file upload |
| FileMetadataResponse | File metadata response from server. |
| FunctionCall | A predicted [FunctionCall] returned from the model that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing the parameters and their values. |
| FunctionCallingConfig | |
| FunctionCallPart | Content part interface if the part represents a FunctionCall. |
| FunctionDeclaration | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. |
| FunctionDeclarationSchema | Schema for parameters passed to FunctionDeclaration.parameters. |
| FunctionDeclarationsTool | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. |
| FunctionResponse | The result output from a [FunctionCall] that contains a string representing the [FunctionDeclaration.name] and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall] made based on model prediction. |
| FunctionResponsePart | Content part interface if the part represents FunctionResponse. |
| GenerativeContentBlob | Interface for sending an image. |
| InlineDataPart | Content part interface if the part represents an image. |
| IntegerSchema | Describes a JSON-encodable integer. |
| ListCacheResponse | |
| ListFilesResponse | Response from calling GoogleAIFileManager.listFiles() |
| ListParams | Params to pass to GoogleAIFileManager.listFiles() or GoogleAICacheManager.list() |
| NumberSchema | Describes a JSON-encodable floating point number. |
| ObjectSchema | Describes a JSON object, a mapping of specific keys to values. |
| RequestOptions | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
| RpcStatus | Standard RPC error status object. |
| SimpleStringSchema | Describes a simple string schema, with or without format |
| SingleRequestOptions | Params passed to atomic asynchronous operations. |
| TextPart | Content part interface if the part represents a text string. |
| ToolConfig | Tool config. This config is shared for all tools provided in the request. |
| UploadFileResponse | Response from calling GoogleAIFileManager.uploadFile() |
| VideoMetadata | Metadata populated when video has been processed. |
Type Aliases
| Type Alias | Description |
|---|---|
| FunctionDeclarationSchemaProperty | Schema for top-level function declaration |
| Part | Content part - includes text or image part types. |
| ResponseSchema | Schema passed to GenerationConfig.responseSchema |
| Schema | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. |
| StringSchema | Describes a string. |
| Tool | Defines a tool that model can call to access external knowledge. |
Reference Server Generative Ai.Numberschema.Format (`docs/reference/server/generative-ai.numberschema.format.md`)
Home > @google/generative-ai > NumberSchema > format
NumberSchema.format property
Optional. The format of the number.
Signature:
format?: "float" | "double";Reference Server Generative Ai.Numberschema (`docs/reference/server/generative-ai.numberschema.md`)
Home > @google/generative-ai > NumberSchema
NumberSchema interface
Describes a JSON-encodable floating point number.
Signature:
export interface NumberSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| format? | "float" | "double" | (Optional) Optional. The format of the number. | |
| type | typeof SchemaType.NUMBER |
Reference Server Generative Ai.Numberschema.Type (`docs/reference/server/generative-ai.numberschema.type.md`)
Home > @google/generative-ai > NumberSchema > type
NumberSchema.type property
Signature:
type: typeof SchemaType.NUMBER;Reference Server Generative Ai.Objectschema (`docs/reference/server/generative-ai.objectschema.md`)
Home > @google/generative-ai > ObjectSchema
ObjectSchema interface
Describes a JSON object, a mapping of specific keys to values.
Signature:
export interface ObjectSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| properties | { [k: string]: Schema; } | Describes the properties of the JSON object. Must not be empty. | |
| required? | string[] | (Optional) A list of keys declared in the properties object. Required properties will always be present in the generated object. | |
| type | typeof SchemaType.OBJECT |
Reference Server Generative Ai.Objectschema.Properties (`docs/reference/server/generative-ai.objectschema.properties.md`)
Home > @google/generative-ai > ObjectSchema > properties
ObjectSchema.properties property
Describes the properties of the JSON object. Must not be empty.
Signature:
properties: {
[k: string]: Schema;
};Reference Server Generative Ai.Objectschema.Required (`docs/reference/server/generative-ai.objectschema.required.md`)
Home > @google/generative-ai > ObjectSchema > required
ObjectSchema.required property
A list of keys declared in the properties object. Required properties will always be present in the generated object.
Signature:
required?: string[];Reference Server Generative Ai.Objectschema.Type (`docs/reference/server/generative-ai.objectschema.type.md`)
Home > @google/generative-ai > ObjectSchema > type
ObjectSchema.type property
Signature:
type: typeof SchemaType.OBJECT;Reference Server Generative Ai.Outcome (`docs/reference/server/generative-ai.outcome.md`)
Home > @google/generative-ai > Outcome
Outcome enum
Possible outcomes of code execution.
Signature:
export declare enum OutcomeEnumeration Members
| Member | Value | Description |
|---|---|---|
| OUTCOME_DEADLINE_EXCEEDED | "outcome_deadline_exceeded" |
Code execution ran for too long, and was cancelled. There may or may not be a partial output present. |
| OUTCOME_FAILED | "outcome_failed" |
Code execution finished but with a failure. stderr should contain the reason. |
| OUTCOME_OK | "outcome_ok" |
Code execution completed successfully. |
| OUTCOME_UNSPECIFIED | "outcome_unspecified" |
Unspecified status. This value should not be used. |
Reference Server Generative Ai.Part (`docs/reference/server/generative-ai.part.md`)
Home > @google/generative-ai > Part
Part type
Content part - includes text or image part types.
Signature:
export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;References: TextPart, InlineDataPart, FunctionCallPart, FunctionResponsePart, FileDataPart, ExecutableCodePart, CodeExecutionResultPart
Reference Server Generative Ai.Requestoptions.Apiclient (`docs/reference/server/generative-ai.requestoptions.apiclient.md`)
Home > @google/generative-ai > RequestOptions > apiClient
RequestOptions.apiClient property
Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs.
Signature:
apiClient?: string;Reference Server Generative Ai.Requestoptions.Apiversion (`docs/reference/server/generative-ai.requestoptions.apiversion.md`)
Home > @google/generative-ai > RequestOptions > apiVersion
RequestOptions.apiVersion property
Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version.
Signature:
apiVersion?: string;Reference Server Generative Ai.Requestoptions.Baseurl (`docs/reference/server/generative-ai.requestoptions.baseurl.md`)
Home > @google/generative-ai > RequestOptions > baseUrl
RequestOptions.baseUrl property
Base endpoint url. Defaults to "https://generativelanguage.googleapis.com"
Signature:
baseUrl?: string;Reference Server Generative Ai.Requestoptions.Customheaders (`docs/reference/server/generative-ai.requestoptions.customheaders.md`)
Home > @google/generative-ai > RequestOptions > customHeaders
RequestOptions.customHeaders property
Custom HTTP request headers.
Signature:
customHeaders?: Headers | Record<string, string>;Reference Server Generative Ai.Requestoptions (`docs/reference/server/generative-ai.requestoptions.md`)
Home > @google/generative-ai > RequestOptions
RequestOptions interface
Params passed to getGenerativeModel() or GoogleAIFileManager().
Signature:
export interface RequestOptionsProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| apiClient? | string | (Optional) Additional attribution information to include in the x-goog-api-client header. Used by wrapper SDKs. | |
| apiVersion? | string | (Optional) Version of API endpoint to call (e.g. "v1" or "v1beta"). If not specified, defaults to latest stable version. | |
| baseUrl? | string | (Optional) Base endpoint url. Defaults to "https://generativelanguage.googleapis.com" | |
| customHeaders? | Headers | Record<string, string> | (Optional) Custom HTTP request headers. | |
| timeout? | number | (Optional) Request timeout in milliseconds. |
Reference Server Generative Ai.Requestoptions.Timeout (`docs/reference/server/generative-ai.requestoptions.timeout.md`)
Home > @google/generative-ai > RequestOptions > timeout
RequestOptions.timeout property
Request timeout in milliseconds.
Signature:
timeout?: number;Reference Server Generative Ai.Responseschema (`docs/reference/server/generative-ai.responseschema.md`)
Home > @google/generative-ai > ResponseSchema
ResponseSchema type
Schema passed to GenerationConfig.responseSchema
Signature:
export type ResponseSchema = Schema;References: Schema
Reference Server Generative Ai.Rpcstatus.Code (`docs/reference/server/generative-ai.rpcstatus.code.md`)
Home > @google/generative-ai > RpcStatus > code
RpcStatus.code property
Error status code
Signature:
code: number;Reference Server Generative Ai.Rpcstatus.Details (`docs/reference/server/generative-ai.rpcstatus.details.md`)
Home > @google/generative-ai > RpcStatus > details
RpcStatus.details property
A list of messages that carry the error details.
Signature:
details?: ErrorDetails[];Reference Server Generative Ai.Rpcstatus (`docs/reference/server/generative-ai.rpcstatus.md`)
Home > @google/generative-ai > RpcStatus
RpcStatus interface
Standard RPC error status object.
Signature:
export interface RpcStatusProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| code | number | Error status code | |
| details? | ErrorDetails[] | (Optional) A list of messages that carry the error details. | |
| message | string | A developer-facing error message. |
Reference Server Generative Ai.Rpcstatus.Message (`docs/reference/server/generative-ai.rpcstatus.message.md`)
Home > @google/generative-ai > RpcStatus > message
RpcStatus.message property
A developer-facing error message.
Signature:
message: string;Reference Server Generative Ai.Schema (`docs/reference/server/generative-ai.schema.md`)
Home > @google/generative-ai > Schema
Schema type
Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed.
Signature:
export type Schema = StringSchema | NumberSchema | IntegerSchema | BooleanSchema | ArraySchema | ObjectSchema;References: StringSchema, NumberSchema, IntegerSchema, BooleanSchema, ArraySchema, ObjectSchema
Reference Server Generative Ai.Schematype (`docs/reference/server/generative-ai.schematype.md`)
Home > @google/generative-ai > SchemaType
SchemaType enum
Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/
Signature:
export declare enum SchemaTypeEnumeration Members
| Member | Value | Description |
|---|---|---|
| ARRAY | "array" |
Array type. |
| BOOLEAN | "boolean" |
Boolean type. |
| INTEGER | "integer" |
Integer type. |
| NUMBER | "number" |
Number type. |
| OBJECT | "object" |
Object type. |
| STRING | "string" |
String type. |
Reference Server Generative Ai.Simplestringschema.Enum (`docs/reference/server/generative-ai.simplestringschema.enum.md`)
Home > @google/generative-ai > SimpleStringSchema > enum
SimpleStringSchema.enum property
Signature:
enum?: never;Reference Server Generative Ai.Simplestringschema.Format (`docs/reference/server/generative-ai.simplestringschema.format.md`)
Home > @google/generative-ai > SimpleStringSchema > format
SimpleStringSchema.format property
Signature:
format?: "date-time" | undefined;Reference Server Generative Ai.Simplestringschema (`docs/reference/server/generative-ai.simplestringschema.md`)
Home > @google/generative-ai > SimpleStringSchema
SimpleStringSchema interface
Describes a simple string schema, with or without format
Signature:
export interface SimpleStringSchema extends BaseSchemaExtends: BaseSchema
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| enum? | never | (Optional) | |
| format? | "date-time" | undefined | (Optional) | |
| type | typeof SchemaType.STRING |
Reference Server Generative Ai.Simplestringschema.Type (`docs/reference/server/generative-ai.simplestringschema.type.md`)
Home > @google/generative-ai > SimpleStringSchema > type
SimpleStringSchema.type property
Signature:
type: typeof SchemaType.STRING;Reference Server Generative Ai.Singlerequestoptions (`docs/reference/server/generative-ai.singlerequestoptions.md`)
Home > @google/generative-ai > SingleRequestOptions
SingleRequestOptions interface
Params passed to atomic asynchronous operations.
Signature:
export interface SingleRequestOptions extends RequestOptionsExtends: RequestOptions
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| signal? | AbortSignal | (Optional) An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided.NOTE: AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations. |
Reference Server Generative Ai.Singlerequestoptions.Signal (`docs/reference/server/generative-ai.singlerequestoptions.signal.md`)
Home > @google/generative-ai > SingleRequestOptions > signal
SingleRequestOptions.signal property
An object that may be used to abort asynchronous requests. The request may also be aborted due to the expiration of the timeout value, if provided.
NOTE: AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations.
Signature:
signal?: AbortSignal;Reference Server Generative Ai.Stringschema (`docs/reference/server/generative-ai.stringschema.md`)
Home > @google/generative-ai > StringSchema
StringSchema type
Describes a string.
Signature:
export type StringSchema = SimpleStringSchema | EnumStringSchema;References: SimpleStringSchema, EnumStringSchema
Reference Server Generative Ai.Textpart.Codeexecutionresult (`docs/reference/server/generative-ai.textpart.codeexecutionresult.md`)
Home > @google/generative-ai > TextPart > codeExecutionResult
TextPart.codeExecutionResult property
Signature:
codeExecutionResult?: never;Reference Server Generative Ai.Textpart.Executablecode (`docs/reference/server/generative-ai.textpart.executablecode.md`)
Home > @google/generative-ai > TextPart > executableCode
TextPart.executableCode property
Signature:
executableCode?: never;Reference Server Generative Ai.Textpart.Filedata (`docs/reference/server/generative-ai.textpart.filedata.md`)
Home > @google/generative-ai > TextPart > fileData
TextPart.fileData property
Signature:
fileData?: never;Reference Server Generative Ai.Textpart.Functioncall (`docs/reference/server/generative-ai.textpart.functioncall.md`)
Home > @google/generative-ai > TextPart > functionCall
TextPart.functionCall property
Signature:
functionCall?: never;Reference Server Generative Ai.Textpart.Functionresponse (`docs/reference/server/generative-ai.textpart.functionresponse.md`)
Home > @google/generative-ai > TextPart > functionResponse
TextPart.functionResponse property
Signature:
functionResponse?: never;Reference Server Generative Ai.Textpart.Inlinedata (`docs/reference/server/generative-ai.textpart.inlinedata.md`)
Home > @google/generative-ai > TextPart > inlineData
TextPart.inlineData property
Signature:
inlineData?: never;Reference Server Generative Ai.Textpart (`docs/reference/server/generative-ai.textpart.md`)
Home > @google/generative-ai > TextPart
TextPart interface
Content part interface if the part represents a text string.
Signature:
export interface TextPartProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| codeExecutionResult? | never | (Optional) | |
| executableCode? | never | (Optional) | |
| fileData? | never | (Optional) | |
| functionCall? | never | (Optional) | |
| functionResponse? | never | (Optional) | |
| inlineData? | never | (Optional) | |
| text | string |
Reference Server Generative Ai.Textpart.Text (`docs/reference/server/generative-ai.textpart.text.md`)
Home > @google/generative-ai > TextPart > text
TextPart.text property
Signature:
text: string;Reference Server Generative Ai.Tool (`docs/reference/server/generative-ai.tool.md`)
Home > @google/generative-ai > Tool
Tool type
Defines a tool that model can call to access external knowledge.
Signature:
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool | GoogleSearchRetrievalTool;References: FunctionDeclarationsTool, CodeExecutionTool
Reference Server Generative Ai.Toolconfig.Functioncallingconfig (`docs/reference/server/generative-ai.toolconfig.functioncallingconfig.md`)
Home > @google/generative-ai > ToolConfig > functionCallingConfig
ToolConfig.functionCallingConfig property
Signature:
functionCallingConfig: FunctionCallingConfig;Reference Server Generative Ai.Toolconfig (`docs/reference/server/generative-ai.toolconfig.md`)
Home > @google/generative-ai > ToolConfig
ToolConfig interface
Tool config. This config is shared for all tools provided in the request.
Signature:
export interface ToolConfigProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| functionCallingConfig | FunctionCallingConfig |
Reference Server Generative Ai.Uploadfileresponse.File (`docs/reference/server/generative-ai.uploadfileresponse.file.md`)
Home > @google/generative-ai > UploadFileResponse > file
UploadFileResponse.file property
Signature:
file: FileMetadataResponse;Reference Server Generative Ai.Uploadfileresponse (`docs/reference/server/generative-ai.uploadfileresponse.md`)
Home > @google/generative-ai > UploadFileResponse
UploadFileResponse interface
Response from calling GoogleAIFileManager.uploadFile()
Signature:
export interface UploadFileResponseProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| file | FileMetadataResponse |
Reference Server Generative Ai.Videometadata (`docs/reference/server/generative-ai.videometadata.md`)
Home > @google/generative-ai > VideoMetadata
VideoMetadata interface
Metadata populated when video has been processed.
Signature:
export interface VideoMetadataProperties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| videoDuration | string | The video duration in protobuf Duration format. |
Reference Server Generative Ai.Videometadata.Videoduration (`docs/reference/server/generative-ai.videometadata.videoduration.md`)
Home > @google/generative-ai > VideoMetadata > videoDuration
VideoMetadata.videoDuration property
The video duration in protobuf Duration format.
Signature:
videoDuration: string;--- METRICS ---
- Files Extracted: 618
- Estimated Token Budget: ~106565 tokens
- Canonical Reference: https://codewiki.google/github.com/google-gemini/generative-ai-js