Provides methods for getting metadata information about Generative Models. v1beta2
Package
@google-ai/generativelanguageConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of ModelServiceClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
modelServiceStub
modelServiceStub?: Promise<{
[name: string]: Function;
}>;
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
scopes
static get scopes(): never[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> |
{Promise} A promise that resolves when the client is closed. |
getModel(request, options)
getModel(request?: protos.google.ai.generativelanguage.v1beta2.IGetModelRequest, options?: CallOptions): Promise<[
protos.google.ai.generativelanguage.v1beta2.IModel,
protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | undefined,
{} | undefined
]>;
Gets information about a specific Model.
Parameters | |
---|---|
Name | Description |
request |
IGetModelRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.ai.generativelanguage.v1beta2.IModel,
protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | undefined,
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing Model. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the model.
* This name should match a model name returned by the `ListModels` method.
* Format: `models/{model}`
*/
// const name = 'abc123'
// Imports the Generativelanguage library
const {ModelServiceClient} = require('@google-ai/generativelanguage').v1beta2;
// Instantiates a client
const generativelanguageClient = new ModelServiceClient();
async function callGetModel() {
// Construct request
const request = {
name,
};
// Run request
const response = await generativelanguageClient.getModel(request);
console.log(response);
}
callGetModel();
getModel(request, options, callback)
getModel(request: protos.google.ai.generativelanguage.v1beta2.IGetModelRequest, options: CallOptions, callback: Callback<protos.google.ai.generativelanguage.v1beta2.IModel, protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetModelRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.ai.generativelanguage.v1beta2.IModel, protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getModel(request, callback)
getModel(request: protos.google.ai.generativelanguage.v1beta2.IGetModelRequest, callback: Callback<protos.google.ai.generativelanguage.v1beta2.IModel, protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetModelRequest
|
callback |
Callback<protos.google.ai.generativelanguage.v1beta2.IModel, protos.google.ai.generativelanguage.v1beta2.IGetModelRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> |
{Promise} A promise that resolves to an authenticated service stub. |
listModels(request, options)
listModels(request?: protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, options?: CallOptions): Promise<[
protos.google.ai.generativelanguage.v1beta2.IModel[],
protos.google.ai.generativelanguage.v1beta2.IListModelsRequest | null,
protos.google.ai.generativelanguage.v1beta2.IListModelsResponse
]>;
Lists models available through the API.
Parameters | |
---|---|
Name | Description |
request |
IListModelsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.ai.generativelanguage.v1beta2.IModel[],
protos.google.ai.generativelanguage.v1beta2.IListModelsRequest | null,
protos.google.ai.generativelanguage.v1beta2.IListModelsResponse
]> |
{Promise} - The promise which resolves to an array. The first element of the array is Array of Model. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listModels(request, options, callback)
listModels(request: protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, options: CallOptions, callback: PaginationCallback<protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, protos.google.ai.generativelanguage.v1beta2.IListModelsResponse | null | undefined, protos.google.ai.generativelanguage.v1beta2.IModel>): void;
Parameters | |
---|---|
Name | Description |
request |
IListModelsRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, protos.google.ai.generativelanguage.v1beta2.IListModelsResponse | null | undefined, protos.google.ai.generativelanguage.v1beta2.IModel>
|
Returns | |
---|---|
Type | Description |
void |
listModels(request, callback)
listModels(request: protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, callback: PaginationCallback<protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, protos.google.ai.generativelanguage.v1beta2.IListModelsResponse | null | undefined, protos.google.ai.generativelanguage.v1beta2.IModel>): void;
Parameters | |
---|---|
Name | Description |
request |
IListModelsRequest
|
callback |
PaginationCallback<protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, protos.google.ai.generativelanguage.v1beta2.IListModelsResponse | null | undefined, protos.google.ai.generativelanguage.v1beta2.IModel>
|
Returns | |
---|---|
Type | Description |
void |
listModelsAsync(request, options)
listModelsAsync(request?: protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, options?: CallOptions): AsyncIterable<protos.google.ai.generativelanguage.v1beta2.IModel>;
Equivalent to listModels
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Parameters | |
---|---|
Name | Description |
request |
IListModelsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.ai.generativelanguage.v1beta2.IModel> |
{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Model. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* The maximum number of `Models` to return (per page).
* The service may return fewer models.
* If unspecified, at most 50 models will be returned per page.
* This method returns at most 1000 models per page, even if you pass a larger
* page_size.
*/
// const pageSize = 1234
/**
* A page token, received from a previous `ListModels` call.
* Provide the `page_token` returned by one request as an argument to the next
* request to retrieve the next page.
* When paginating, all other parameters provided to `ListModels` must match
* the call that provided the page token.
*/
// const pageToken = 'abc123'
// Imports the Generativelanguage library
const {ModelServiceClient} = require('@google-ai/generativelanguage').v1beta2;
// Instantiates a client
const generativelanguageClient = new ModelServiceClient();
async function callListModels() {
// Construct request
const request = {
};
// Run request
const iterable = generativelanguageClient.listModelsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListModels();
listModelsStream(request, options)
listModelsStream(request?: protos.google.ai.generativelanguage.v1beta2.IListModelsRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Parameters | |
---|---|
Name | Description |
request |
IListModelsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Transform |
{Stream} An object stream which emits an object representing Model on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
matchModelFromModelName(modelName)
matchModelFromModelName(modelName: string): string | number;
Parse the model from Model resource.
Parameter | |
---|---|
Name | Description |
modelName |
string
A fully-qualified path representing Model resource. |
Returns | |
---|---|
Type | Description |
string | number |
{string} A string representing the model. |
modelPath(model)
modelPath(model: string): string;
Return a fully-qualified model resource name string.
Parameter | |
---|---|
Name | Description |
model |
string
|
Returns | |
---|---|
Type | Description |
string |
{string} Resource name string. |