Abstract
Abstract
getThe 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).
Static
parseInternal
Turns a string embedding api key into an EmbeddingAPIKeyHeaderProvider if necessary. Throws an error if
it's not a string, nullish, or a EmbeddingHeadersProvider
already.
Not intended for external use.
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
See