generative-ai-js Documentation

This SDK is now deprecated, use the new unified Google GenAI SDK.

1,234 stars TypeScript TypeScript 1 file · ~106,655 tokens
RAW Doc

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:

text
node function_calling.js

Some 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 SDK
  • chat.html - demonstrates the Multi-turn Conversations feature from the SDK

Documentation


Reference Files Index (`docs/reference/files/index.md`)

Home

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
startIndex?: number;

Reference Main Index (`docs/reference/main/index.md`)

Home

API Reference

Packages

Package Description
@google/generative-ai

Reference Server Index (`docs/reference/server/index.md`)

Home

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:

  1. clone this repo
  2. cd generative-ai-js
  3. Run npm install to install dependencies.
  4. Make changes as needed to source code.
  5. Run npm run build to build.
  6. Run npm run test to run unit tests.
  7. Run npm run docs to generate any changes to reference docs (destination dir is docs/reference).
  8. Run npm run format to fix formatting and add license headers as needed.
  9. Run npx @changesets/cli to 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:

typescript
"@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:

typescript
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:

typescript
export interface ErrorDetails

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FileMetadata

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FileMetadataResponse

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare enum FileState

Enumeration Members

Member Value Description
ACTIVE &quot;ACTIVE&quot;
FAILED &quot;FAILED&quot;
PROCESSING &quot;PROCESSING&quot;
STATE_UNSPECIFIED &quot;STATE_UNSPECIFIED&quot;

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare class GoogleAIFileManager

Constructors

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:

typescript
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:

typescript
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:

typescript
export interface ListFilesResponse

Properties

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:

typescript
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:

typescript
export interface ListParams

Properties

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:

typescript
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:

typescript
pageToken?: string;

Reference Files Generative Ai (`docs/reference/files/generative-ai.md`)

Home > @google/generative-ai

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface RequestOptions

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface RpcStatus

Properties

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:

typescript
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:

typescript
export interface SingleRequestOptions extends RequestOptions

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface UploadFileResponse

Properties

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:

typescript
export interface VideoMetadata

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ArraySchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface BaseParams

Properties

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:

typescript
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:

typescript
export interface BatchEmbedContentsRequest

Properties

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:

typescript
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:

typescript
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:

typescript
export interface BatchEmbedContentsResponse

Properties

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:

typescript
export declare enum BlockReason

Enumeration Members

Member Value Description
BLOCKED_REASON_UNSPECIFIED &quot;BLOCKED_REASON_UNSPECIFIED&quot;
OTHER &quot;OTHER&quot;
SAFETY &quot;SAFETY&quot;

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:

typescript
export interface BooleanSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface CachedContent extends CachedContentBase

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
expireTime?: string;

Reference Main Generative Ai.Cachedcontentbase (`docs/reference/main/generative-ai.cachedcontentbase.md`)

Home > @google/generative-ai > CachedContentBase

CachedContentBase interface

Signature:

typescript
export interface CachedContentBase

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare class ChatSession

Constructors

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface CitationMetadata

Properties

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:

typescript
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:

typescript
export interface CitationSource

Properties

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:

typescript
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:

typescript
export interface CodeExecutionResult

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface CodeExecutionResultPart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface CodeExecutionTool

Properties

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:

typescript
export interface Content

Properties

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:

typescript
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:

typescript
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:

typescript
export interface ContentEmbedding

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface CountTokensRequest

Properties

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:

typescript
export interface CountTokensResponse

Properties

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:

typescript
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:

typescript
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:

typescript
export declare interface DynamicRetrievalConfig

Properties

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:

typescript
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:

typescript
export declare enum DynamicRetrievalMode

Enumeration Members

Member Value Description
MODE_DYNAMIC &quot;MODE_DYNAMIC&quot;
MODE_UNSPECIFIED &quot;MODE_UNSPECIFIED&quot;

Reference Main Generative Ai.Embedcontentrequest.Content (`docs/reference/main/generative-ai.embedcontentrequest.content.md`)

Home > @google/generative-ai > EmbedContentRequest > content

EmbedContentRequest.content property

Signature:

typescript
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:

typescript
export interface EmbedContentRequest

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface EmbedContentResponse

Properties

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:

typescript
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:

typescript
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:

typescript
export interface EnhancedGenerateContentResponse extends GenerateContentResponse

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface EnumStringSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
"@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:

typescript
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:

typescript
export interface ErrorDetails

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ExecutableCode

Properties

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:

typescript
export declare enum ExecutableCodeLanguage

Enumeration Members

Member Value Description
LANGUAGE_UNSPECIFIED &quot;language_unspecified&quot;
PYTHON &quot;python&quot;

Reference Main Generative Ai.Executablecodepart.Codeexecutionresult (`docs/reference/main/generative-ai.executablecodepart.codeexecutionresult.md`)

Home > @google/generative-ai > ExecutableCodePart > codeExecutionResult

ExecutableCodePart.codeExecutionResult property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ExecutableCodePart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface FileData

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FileDataPart

Properties

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:

typescript
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:

typescript
export declare enum FinishReason

Enumeration Members

Member Value Description
BLOCKLIST &quot;BLOCKLIST&quot;
FINISH_REASON_UNSPECIFIED &quot;FINISH_REASON_UNSPECIFIED&quot;
LANGUAGE &quot;LANGUAGE&quot;
MALFORMED_FUNCTION_CALL &quot;MALFORMED_FUNCTION_CALL&quot;
MAX_TOKENS &quot;MAX_TOKENS&quot;
OTHER &quot;OTHER&quot;
PROHIBITED_CONTENT &quot;PROHIBITED_CONTENT&quot;
RECITATION &quot;RECITATION&quot;
SAFETY &quot;SAFETY&quot;
SPII &quot;SPII&quot;
STOP &quot;STOP&quot;

Reference Main Generative Ai.Functioncall.Args (`docs/reference/main/generative-ai.functioncall.args.md`)

Home > @google/generative-ai > FunctionCall > args

FunctionCall.args property

Signature:

typescript
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:

typescript
export interface FunctionCall

Properties

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:

typescript
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:

typescript
allowedFunctionNames?: string[];

Reference Main Generative Ai.Functioncallingconfig (`docs/reference/main/generative-ai.functioncallingconfig.md`)

Home > @google/generative-ai > FunctionCallingConfig

FunctionCallingConfig interface

Signature:

typescript
export interface FunctionCallingConfig

Properties

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:

typescript
mode?: FunctionCallingMode;

Reference Main Generative Ai.Functioncallingmode (`docs/reference/main/generative-ai.functioncallingmode.md`)

Home > @google/generative-ai > FunctionCallingMode

FunctionCallingMode enum

Signature:

typescript
export declare enum FunctionCallingMode

Enumeration Members

Member Value Description
ANY &quot;ANY&quot;
AUTO &quot;AUTO&quot;
MODE_UNSPECIFIED &quot;MODE_UNSPECIFIED&quot;
NONE &quot;NONE&quot;

Reference Main Generative Ai.Functioncallpart.Codeexecutionresult (`docs/reference/main/generative-ai.functioncallpart.codeexecutionresult.md`)

Home > @google/generative-ai > FunctionCallPart > codeExecutionResult

FunctionCallPart.codeExecutionResult property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FunctionCallPart

Properties

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:

typescript
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:

typescript
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:

typescript
export declare interface FunctionDeclaration

Properties

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:

typescript
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:

typescript
parameters?: FunctionDeclarationSchema;

Example

with 1 required and 1 optional parameter: type: OBJECT properties:

text
param1:

  type: STRING
param2:

 type: INTEGER
required:

  - param1

Reference 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:

typescript
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:

typescript
export interface FunctionDeclarationSchema

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare interface FunctionDeclarationsTool

Properties

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:

typescript
export interface FunctionResponse

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FunctionResponsePart

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface GenerateContentCandidate

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface GenerateContentRequest extends BaseParams

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface GenerateContentResponse

Properties

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:

typescript
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:

typescript
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:

typescript
export interface GenerateContentResult

Properties

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:

typescript
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:

typescript
export interface GenerateContentStreamResult

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface GenerationConfig

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface GenerativeContentBlob

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare class GenerativeModel

Constructors

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:

typescript
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:

typescript
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:

typescript
startChat(startChatParams?: StartChatParams): ChatSession;

Parameters

Parameter Type Description
startChatParams StartChatParams (Optional)

Returns:

ChatSession


Reference Main Generative Ai.Generativemodel.Systeminstruction (`docs/reference/main/generative-ai.generativemodel.systeminstruction.md`)

Home > @google/generative-ai > GenerativeModel > systemInstruction

GenerativeModel.systemInstruction property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
getGenerativeModel(modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel;

Parameters

Parameter Type Description
modelParams ModelParams
requestOptions RequestOptions (Optional)

Returns:

GenerativeModel


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:

typescript
getGenerativeModelFromCachedContent(cachedContent: CachedContent, modelParams?: Partial<ModelParams>, requestOptions?: RequestOptions): GenerativeModel;

Parameters

Parameter Type Description
cachedContent CachedContent
modelParams Partial<ModelParams> (Optional)
requestOptions RequestOptions (Optional)

Returns:

GenerativeModel


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:

typescript
export declare class GoogleGenerativeAI

Constructors

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:

typescript
export declare class GoogleGenerativeAIAbortError extends GoogleGenerativeAIError

Extends: 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:

typescript
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:

typescript
export declare class GoogleGenerativeAIError extends Error

Extends: 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:

typescript
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:

typescript
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:

typescript
export declare class GoogleGenerativeAIFetchError extends GoogleGenerativeAIError

Extends: 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:

typescript
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:

typescript
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:

typescript
export declare class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIError

Extends: 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:

typescript
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:

typescript
export declare class GoogleGenerativeAIResponseError<T> extends GoogleGenerativeAIError

Extends: 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:

typescript
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:

typescript
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:

typescript
export declare interface GoogleSearchRetrieval

Properties

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:

typescript
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:

typescript
export declare interface GoogleSearchRetrievalTool

Properties

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:

typescript
export declare interface GroundingChunk

Properties

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:

typescript
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:

typescript
export declare interface GroundingChunkWeb

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare interface GroundingMetadata

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
groundingChunckIndices?: number[];

Reference Main Generative Ai.Groundingsupport (`docs/reference/main/generative-ai.groundingsupport.md`)

Home > @google/generative-ai > GroundingSupport

GroundingSupport interface

Grounding support.

Signature:

typescript
export declare interface GroundingSupport

Properties

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:

typescript
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:

typescript
export declare interface GroundingSupportSegment

Properties

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:

typescript
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:

typescript
export declare enum HarmBlockThreshold

Enumeration Members

Member Value Description
BLOCK_LOW_AND_ABOVE &quot;BLOCK_LOW_AND_ABOVE&quot; Content with NEGLIGIBLE will be allowed.
BLOCK_MEDIUM_AND_ABOVE &quot;BLOCK_MEDIUM_AND_ABOVE&quot; Content with NEGLIGIBLE and LOW will be allowed.
BLOCK_NONE &quot;BLOCK_NONE&quot; All content will be allowed.
BLOCK_ONLY_HIGH &quot;BLOCK_ONLY_HIGH&quot; Content with NEGLIGIBLE, LOW, and MEDIUM will be allowed.
HARM_BLOCK_THRESHOLD_UNSPECIFIED &quot;HARM_BLOCK_THRESHOLD_UNSPECIFIED&quot; 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:

typescript
export declare enum HarmCategory

Enumeration Members

Member Value Description
HARM_CATEGORY_CIVIC_INTEGRITY &quot;HARM_CATEGORY_CIVIC_INTEGRITY&quot;
HARM_CATEGORY_DANGEROUS_CONTENT &quot;HARM_CATEGORY_DANGEROUS_CONTENT&quot;
HARM_CATEGORY_HARASSMENT &quot;HARM_CATEGORY_HARASSMENT&quot;
HARM_CATEGORY_HATE_SPEECH &quot;HARM_CATEGORY_HATE_SPEECH&quot;
HARM_CATEGORY_SEXUALLY_EXPLICIT &quot;HARM_CATEGORY_SEXUALLY_EXPLICIT&quot;
HARM_CATEGORY_UNSPECIFIED &quot;HARM_CATEGORY_UNSPECIFIED&quot;

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:

typescript
export declare enum HarmProbability

Enumeration Members

Member Value Description
HARM_PROBABILITY_UNSPECIFIED &quot;HARM_PROBABILITY_UNSPECIFIED&quot; Probability is unspecified.
HIGH &quot;HIGH&quot; Content has a high chance of being unsafe.
LOW &quot;LOW&quot; Content has a low chance of being unsafe.
MEDIUM &quot;MEDIUM&quot; Content has a medium chance of being unsafe.
NEGLIGIBLE &quot;NEGLIGIBLE&quot; 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface InlineDataPart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface IntegerSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface LogprobsCandidate

Properties

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:

typescript
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:

typescript
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:

typescript
chosenCandidates: LogprobsCandidate[];

Reference Main Generative Ai.Logprobsresult (`docs/reference/main/generative-ai.logprobsresult.md`)

Home > @google/generative-ai > LogprobsResult

LogprobsResult interface

Logprobs Result

Signature:

typescript
export interface LogprobsResult

Properties

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:

typescript
topCandidates: TopCandidates[];

Reference Main Generative Ai (`docs/reference/main/generative-ai.md`)

Home > @google/generative-ai

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:

typescript
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:

typescript
export interface ModelParams extends BaseParams

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface NumberSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
export interface ObjectSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare enum Outcome

Enumeration Members

Member Value Description
OUTCOME_DEADLINE_EXCEEDED &quot;outcome_deadline_exceeded&quot; Code execution ran for too long, and was cancelled. There may or may not be a partial output present.
OUTCOME_FAILED &quot;outcome_failed&quot; Code execution finished but with a failure. stderr should contain the reason.
OUTCOME_OK &quot;outcome_ok&quot; Code execution completed successfully.
OUTCOME_UNSPECIFIED &quot;outcome_unspecified&quot; 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface PromptFeedback

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface RequestOptions

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare interface RetrievalMetadata

Properties

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:

typescript
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:

typescript
export interface SafetyRating

Properties

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:

typescript
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:

typescript
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:

typescript
export interface SafetySetting

Properties

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:

typescript
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:

typescript
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:

typescript
export declare enum SchemaType

Enumeration Members

Member Value Description
ARRAY &quot;array&quot; Array type.
BOOLEAN &quot;boolean&quot; Boolean type.
INTEGER &quot;integer&quot; Integer type.
NUMBER &quot;number&quot; Number type.
OBJECT &quot;object&quot; Object type.
STRING &quot;string&quot; 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:

typescript
export declare interface SearchEntryPoint

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface SimpleStringSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
export interface SingleRequestOptions extends RequestOptions

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface StartChatParams extends BaseParams

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare enum TaskType

Enumeration Members

Member Value Description
CLASSIFICATION &quot;CLASSIFICATION&quot;
CLUSTERING &quot;CLUSTERING&quot;
RETRIEVAL_DOCUMENT &quot;RETRIEVAL_DOCUMENT&quot;
RETRIEVAL_QUERY &quot;RETRIEVAL_QUERY&quot;
SEMANTIC_SIMILARITY &quot;SEMANTIC_SIMILARITY&quot;
TASK_TYPE_UNSPECIFIED &quot;TASK_TYPE_UNSPECIFIED&quot;

Reference Main Generative Ai.Textpart.Codeexecutionresult (`docs/reference/main/generative-ai.textpart.codeexecutionresult.md`)

Home > @google/generative-ai > TextPart > codeExecutionResult

TextPart.codeExecutionResult property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface TextPart

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ToolConfig

Properties

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:

typescript
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:

typescript
export interface TopCandidates

Properties

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:

typescript
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:

typescript
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:

typescript
export interface UsageMetadata

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ArraySchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface BooleanSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface CachedContent extends CachedContentBase

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
expireTime?: string;

Reference Server Generative Ai.Cachedcontentbase (`docs/reference/server/generative-ai.cachedcontentbase.md`)

Home > @google/generative-ai > CachedContentBase

CachedContentBase interface

Signature:

typescript
export interface CachedContentBase

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface CachedContentCreateParams extends CachedContentBase

Extends: 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:

typescript
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:

typescript
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:

typescript
export interface CachedContentUpdateInputFields

Properties

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:

typescript
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:

typescript
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:

typescript
export interface CachedContentUpdateParams

Properties

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:

typescript
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:

typescript
export interface CodeExecutionResult

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface CodeExecutionResultPart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface CodeExecutionTool

Properties

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:

typescript
export interface Content

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface EnumStringSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
"@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:

typescript
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:

typescript
export interface ErrorDetails

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ExecutableCode

Properties

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:

typescript
export declare enum ExecutableCodeLanguage

Enumeration Members

Member Value Description
LANGUAGE_UNSPECIFIED &quot;language_unspecified&quot;
PYTHON &quot;python&quot;

Reference Server Generative Ai.Executablecodepart.Codeexecutionresult (`docs/reference/server/generative-ai.executablecodepart.codeexecutionresult.md`)

Home > @google/generative-ai > ExecutableCodePart > codeExecutionResult

ExecutableCodePart.codeExecutionResult property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ExecutableCodePart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface FileData

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FileDataPart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface FileMetadata

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FileMetadataResponse

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare enum FileState

Enumeration Members

Member Value Description
ACTIVE &quot;ACTIVE&quot;
FAILED &quot;FAILED&quot;
PROCESSING &quot;PROCESSING&quot;
STATE_UNSPECIFIED &quot;STATE_UNSPECIFIED&quot;

Reference Server Generative Ai.Functioncall.Args (`docs/reference/server/generative-ai.functioncall.args.md`)

Home > @google/generative-ai > FunctionCall > args

FunctionCall.args property

Signature:

typescript
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:

typescript
export interface FunctionCall

Properties

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:

typescript
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:

typescript
allowedFunctionNames?: string[];

Reference Server Generative Ai.Functioncallingconfig (`docs/reference/server/generative-ai.functioncallingconfig.md`)

Home > @google/generative-ai > FunctionCallingConfig

FunctionCallingConfig interface

Signature:

typescript
export interface FunctionCallingConfig

Properties

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:

typescript
mode?: FunctionCallingMode;

Reference Server Generative Ai.Functioncallingmode (`docs/reference/server/generative-ai.functioncallingmode.md`)

Home > @google/generative-ai > FunctionCallingMode

FunctionCallingMode enum

Signature:

typescript
export declare enum FunctionCallingMode

Enumeration Members

Member Value Description
ANY &quot;ANY&quot;
AUTO &quot;AUTO&quot;
MODE_UNSPECIFIED &quot;MODE_UNSPECIFIED&quot;
NONE &quot;NONE&quot;

Reference Server Generative Ai.Functioncallpart.Codeexecutionresult (`docs/reference/server/generative-ai.functioncallpart.codeexecutionresult.md`)

Home > @google/generative-ai > FunctionCallPart > codeExecutionResult

FunctionCallPart.codeExecutionResult property

Signature:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FunctionCallPart

Properties

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:

typescript
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:

typescript
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:

typescript
export declare interface FunctionDeclaration

Properties

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:

typescript
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:

typescript
parameters?: FunctionDeclarationSchema;

Example

with 1 required and 1 optional parameter: type: OBJECT properties:

text
param1:

  type: STRING
param2:

 type: INTEGER
required:

  - param1

Reference 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:

typescript
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:

typescript
export interface FunctionDeclarationSchema

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare interface FunctionDeclarationsTool

Properties

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:

typescript
export interface FunctionResponse

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface FunctionResponsePart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface GenerativeContentBlob

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare class GoogleAICacheManager

Constructors

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare class GoogleAIFileManager

Constructors

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface InlineDataPart

Properties

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:

typescript
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:

typescript
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:

typescript
export interface IntegerSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
cachedContents: CachedContent[];

Reference Server Generative Ai.Listcacheresponse (`docs/reference/server/generative-ai.listcacheresponse.md`)

Home > @google/generative-ai > ListCacheResponse

ListCacheResponse interface

Signature:

typescript
export interface ListCacheResponse

Properties

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:

typescript
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:

typescript
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:

typescript
export interface ListFilesResponse

Properties

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:

typescript
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:

typescript
export interface ListParams

Properties

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:

typescript
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:

typescript
pageToken?: string;

Reference Server Generative Ai (`docs/reference/server/generative-ai.md`)

Home > @google/generative-ai

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:

typescript
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:

typescript
export interface NumberSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
export interface ObjectSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
export declare enum Outcome

Enumeration Members

Member Value Description
OUTCOME_DEADLINE_EXCEEDED &quot;outcome_deadline_exceeded&quot; Code execution ran for too long, and was cancelled. There may or may not be a partial output present.
OUTCOME_FAILED &quot;outcome_failed&quot; Code execution finished but with a failure. stderr should contain the reason.
OUTCOME_OK &quot;outcome_ok&quot; Code execution completed successfully.
OUTCOME_UNSPECIFIED &quot;outcome_unspecified&quot; 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface RequestOptions

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface RpcStatus

Properties

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:

typescript
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:

typescript
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:

typescript
export declare enum SchemaType

Enumeration Members

Member Value Description
ARRAY &quot;array&quot; Array type.
BOOLEAN &quot;boolean&quot; Boolean type.
INTEGER &quot;integer&quot; Integer type.
NUMBER &quot;number&quot; Number type.
OBJECT &quot;object&quot; Object type.
STRING &quot;string&quot; 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:

typescript
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:

typescript
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:

typescript
export interface SimpleStringSchema extends BaseSchema

Extends: 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:

typescript
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:

typescript
export interface SingleRequestOptions extends RequestOptions

Extends: 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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface TextPart

Properties

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:

typescript
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:

typescript
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:

typescript
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:

typescript
export interface ToolConfig

Properties

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:

typescript
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:

typescript
export interface UploadFileResponse

Properties

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:

typescript
export interface VideoMetadata

Properties

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:

typescript
videoDuration: string;

--- METRICS ---