Interface: KeyStrategy
@providerprotocol/ai / @providerprotocol/ai / KeyStrategy
Interface: KeyStrategy
Section titled “Interface: KeyStrategy”Defined in: src/types/provider.ts:33
API key strategy interface for managing multiple keys.
Implement this interface to provide custom key rotation or selection logic when working with multiple API keys.
Example
Section titled “Example”// Built-in key strategiesconst keys = roundRobinKeys(['sk-key-1', 'sk-key-2']);
// Custom implementationconst custom: KeyStrategy = { getKey(): string { return pickKeyFromPool(); }};Methods
Section titled “Methods”getKey()
Section titled “getKey()”getKey():
string|Promise<string>
Defined in: src/types/provider.ts:39
Gets the next API key to use for a request.
Returns
Section titled “Returns”string | Promise<string>
The API key string, or a Promise resolving to it