Interface: ProviderConfig
@providerprotocol/ai / @providerprotocol/ai / ProviderConfig
Interface: ProviderConfig
Section titled “Interface: ProviderConfig”Defined in: src/types/provider.ts:156
Provider configuration for infrastructure and connection settings.
These settings control how requests are made to the provider’s API, including authentication, timeouts, and retry behavior.
Example
Section titled “Example”const config: ProviderConfig = { apiKey: process.env.OPENAI_API_KEY, timeout: 30000, retryStrategy: exponentialBackoff()};
// Or with a key strategy for key rotationconst config: ProviderConfig = { apiKey: roundRobinKeys(['sk-1', 'sk-2', 'sk-3']), baseUrl: 'https://custom-proxy.example.com'};Properties
Section titled “Properties”apiKey?
Section titled “apiKey?”
optionalapiKey:string|KeyStrategy| () =>string|Promise<string>
Defined in: src/types/provider.ts:161
API key for authentication. Can be a string, async function, or KeyStrategy for advanced use cases.
apiVersion?
Section titled “apiVersion?”
optionalapiVersion:string
Defined in: src/types/provider.ts:176
API version override (provider-specific)
baseUrl?
Section titled “baseUrl?”
optionalbaseUrl:string
Defined in: src/types/provider.ts:164
Override the base API URL (for proxies, local models)
fetch?
Section titled “fetch?”
optionalfetch: typeoffetch
Defined in: src/types/provider.ts:173
Custom fetch implementation (for logging, caching, custom TLS)
headers?
Section titled “headers?”
optionalheaders:Record<string,string|undefined>
Defined in: src/types/provider.ts:197
Custom headers to include in API requests.
Use this to pass provider-specific headers such as:
- Anthropic:
anthropic-betafor beta features - OpenAI:
OpenAI-Organization,OpenAI-Project - OpenRouter:
HTTP-Referer,X-Titlefor attribution - Ollama: Proxy authentication headers
Example
Section titled “Example”const config: ProviderConfig = { headers: { 'anthropic-beta': 'extended-cache-ttl-2025-04-11' }};retryAfterMaxSeconds?
Section titled “retryAfterMaxSeconds?”
optionalretryAfterMaxSeconds:number
Defined in: src/types/provider.ts:203
Maximum Retry-After delay in seconds when honoring server headers. Defaults to 3600 seconds (1 hour).
retryStrategy?
Section titled “retryStrategy?”
optionalretryStrategy:RetryStrategyFactory
Defined in: src/types/provider.ts:179
Retry strategy factory for handling failures and rate limits
timeout?
Section titled “timeout?”
optionaltimeout:number
Defined in: src/types/provider.ts:170
Request timeout in milliseconds. Applied per attempt; total wall time can exceed this when retries are enabled.