Class EmbeddingHeadersProviderAbstract

The base class for an "embedding headers provider", a general concept for anything that provides headers used for vectorize operations on a per-call basis, whether the headers be static, dynamically fetched at runtime, or periodically refreshed/cycled.

The EmbeddingHeadersProvider.getHeaders function is called for every request to the Data API, regardless of if vectorize is being utilized or not. Note that this is called for every individual request on multipart operations, such as insertMany or find.

astra-db-ts provides all the main embedding headers providers you may ever need to use, but you're able to extend this class to create your own if you find it necessary.

Generally, where you can pass in a EmbeddingHeadersProvider, you may also pass in a plain string which is translated into an EmbeddingAPIKeyHeaderProvider under the hood.

Example

// Using explicit `EmbeddingHeadersProvider`
const provider = new AWSEmbeddingHeadersProvider('access-key-id', 'secret-access-key');
const coll1 = await db.collection('my_coll1', { embeddingApiKey: provider });

// Implicitly converted to `EmbeddingAPIKeyHeaderProvider`
const coll2 = await db.collection('my_coll2', { embeddingApiKey: 'sk-...' });

See

  • EmbeddingAPIKeyHeaderProvider
  • AWSEmbeddingHeadersProvider

Hierarchy (view full)

Constructors

Methods

Constructors

Methods

  • The function which provides the headers.

    It may do any I/O as it wishes to obtain/refresh the token, as it's called for every request to the Data API.

    If no promise is returned, it will not be awaited (no minor performance impact).

    Returns Record<string, string> | Promise<Record<string, string>>