Skip to navigation

The TwelveLabs class

The TwelveLabs class is the main entry point for the SDK. It initializes the client and provides access to all the resources.

Methods

The constructor

Description: The constructor creates a new instance of the TwelveLabs class.

Function signature and example:

constructor({ apiKey, timeoutInSeconds }: {
apiKey?: string;
timeoutInSeconds?: number;
});

Parameters

NameTypeRequiredDescription
apiKeystringNoYour TwelveLabs API key. If not provided, the TWELVE_LABS_API_KEY environment variable will be used.
timeoutInSecondsnumberNoRequest timeout in seconds. Defaults to 600. For long-running endpoints (embed or analyze with large inputs), pass a higher value. For fast-fail behavior, pass a lower value, or override per call by passing { timeoutInSeconds: N } as the second argument to any SDK method.

Return value

Implicitly returns the newly created instance.

Request options

Every method accepts an optional final requestOptions argument for per-call configuration:

await client.knowledgeStores.list(
{},
{ timeoutInSeconds: 30 },
);

The requestOptions argument accepts the following fields:

NameTypeDescription
timeoutInSecondsnumberThe request timeout, in seconds, for this call. Overrides the client’s default timeout of 600 seconds. For long-running endpoints (embed or analyze with large inputs), pass a higher value. For fast-fail behavior, pass a lower value.
maxRetriesnumberThe number of times to retry the request. Defaults to 2.
abortSignalAbortSignalA hook to abort the request.
headersRecord<string, string>Additional headers to include in the request.