Skip to content

Interface: ProviderConfig

@providerprotocol/ai


@providerprotocol/ai / @providerprotocol/ai / 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.

const config: ProviderConfig = {
apiKey: process.env.OPENAI_API_KEY,
timeout: 30000,
retryStrategy: exponentialBackoff()
};
// Or with a key strategy for key rotation
const config: ProviderConfig = {
apiKey: roundRobinKeys(['sk-1', 'sk-2', 'sk-3']),
baseUrl: 'https://custom-proxy.example.com'
};

optional apiKey: 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.


optional apiVersion: string

Defined in: src/types/provider.ts:176

API version override (provider-specific)


optional baseUrl: string

Defined in: src/types/provider.ts:164

Override the base API URL (for proxies, local models)


optional fetch: typeof fetch

Defined in: src/types/provider.ts:173

Custom fetch implementation (for logging, caching, custom TLS)


optional headers: 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-beta for beta features
  • OpenAI: OpenAI-Organization, OpenAI-Project
  • OpenRouter: HTTP-Referer, X-Title for attribution
  • Ollama: Proxy authentication headers
const config: ProviderConfig = {
headers: { 'anthropic-beta': 'extended-cache-ttl-2025-04-11' }
};

optional retryAfterMaxSeconds: number

Defined in: src/types/provider.ts:203

Maximum Retry-After delay in seconds when honoring server headers. Defaults to 3600 seconds (1 hour).


optional retryStrategy: RetryStrategyFactory

Defined in: src/types/provider.ts:179

Retry strategy factory for handling failures and rate limits


optional timeout: 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.