Interface: ProviderConfig
Defined in: packages/core/src/providers/types.ts:51
Provider configuration. Networking customisation is ordinary config: baseUrl/proxyUrl, headers, and a fetch override.
Examples
Custom API key
const config: ProviderConfig = {
apiKey: 'sk-...',
baseUrl: 'https://custom-endpoint.com/v1'
};
Tauri desktop app
import { fetch as tauriFetch } from '@tauri-apps/api/http';
const config: ProviderConfig = {
fetch: tauriFetch
};
Retry logic
const config: ProviderConfig = {
fetch: async (url, init) => {
for (let attempt = 1; ; attempt++) {
const response = await globalThis.fetch(url, init);
if (response.status < 500 || attempt === 3) return response;
}
}
};
Properties
apiKey?
optionalapiKey?:string
Defined in: packages/core/src/providers/types.ts:56
API key for the provider. Falls back to the provider's environment
variables (its catalog entry's envKeys, e.g. OPENAI_API_KEY).
baseUrl?
optionalbaseUrl?:string
Defined in: packages/core/src/providers/types.ts:59
Defaults to the provider's official endpoint.
fetch?
optionalfetch?: {(input,init?):Promise<Response>; (input,init?):Promise<Response>; }
Defined in: packages/core/src/providers/types.ts:85
Replaces globalThis.fetch for every request: Tauri IPC, React Native
networking, test mocks, retries, logging.
Call Signature
(
input,init?):Promise<Response>
Parameters
input
RequestInfo | URL
init?
RequestInit
Returns
Promise<Response>
Call Signature
(
input,init?):Promise<Response>
Parameters
input
string | Request | URL
init?
RequestInit
Returns
Promise<Response>
headers?
optionalheaders?:Record<string,string>
Defined in: packages/core/src/providers/types.ts:79
providerOptions?
optionalproviderOptions?:Record<string,Record<string,unknown>>
Defined in: packages/core/src/providers/types.ts:88
Provider-specific knobs passed through without core interpreting them.
proxyUrl?
optionalproxyUrl?:string
Defined in: packages/core/src/providers/types.ts:77
Routes every request through a backend proxy server, to avoid CORS
errors in the browser. In a browser without a custom fetch, a bot
defaults this to the page's origin.
Example
import { anthropic } from '@baleybots/core';
const model = anthropic('claude-3-5-sonnet', {
proxyUrl: 'https://api.myapp.com' // Routes through your proxy
});
See
https://github.com/baleybots/baleybots/tree/main/packages/proxy-server for server setup