@chinmaymk/aikit / createProvider
Function: createProvider()
Call Signature
createProvider(
type
,options
):OpenAIProvider
Defined in: factory.ts:238
Generic provider factory for generation providers with strong typing. This is the default factory for text generation providers. Returns a narrowed type based on the provider type.
Parameters
type
"openai"
options
Returns
Example
// Strongly typed - options are specific to the provider type
const openai = createProvider('openai', {
apiKey: 'sk-...',
model: 'gpt-4o',
temperature: 0.7
});
const anthropic = createProvider('anthropic', {
apiKey: 'sk-ant-...',
model: 'claude-3-5-sonnet-20241022',
topK: 40 // Anthropic-specific option
});
Call Signature
createProvider(
type
,options
):AnthropicProvider
Defined in: factory.ts:239
Generic provider factory for generation providers with strong typing. This is the default factory for text generation providers. Returns a narrowed type based on the provider type.
Parameters
type
"anthropic"
options
Returns
Example
// Strongly typed - options are specific to the provider type
const openai = createProvider('openai', {
apiKey: 'sk-...',
model: 'gpt-4o',
temperature: 0.7
});
const anthropic = createProvider('anthropic', {
apiKey: 'sk-ant-...',
model: 'claude-3-5-sonnet-20241022',
topK: 40 // Anthropic-specific option
});
Call Signature
createProvider(
type
,options
):GoogleProvider
Defined in: factory.ts:243
Generic provider factory for generation providers with strong typing. This is the default factory for text generation providers. Returns a narrowed type based on the provider type.
Parameters
type
"google"
options
Returns
Example
// Strongly typed - options are specific to the provider type
const openai = createProvider('openai', {
apiKey: 'sk-...',
model: 'gpt-4o',
temperature: 0.7
});
const anthropic = createProvider('anthropic', {
apiKey: 'sk-ant-...',
model: 'claude-3-5-sonnet-20241022',
topK: 40 // Anthropic-specific option
});
Call Signature
createProvider(
type
,options
):OpenAIResponsesProvider
Defined in: factory.ts:244
Generic provider factory for generation providers with strong typing. This is the default factory for text generation providers. Returns a narrowed type based on the provider type.
Parameters
type
"openai_responses"
options
WithApiKey
<OpenAIResponsesOptions
>
Returns
Example
// Strongly typed - options are specific to the provider type
const openai = createProvider('openai', {
apiKey: 'sk-...',
model: 'gpt-4o',
temperature: 0.7
});
const anthropic = createProvider('anthropic', {
apiKey: 'sk-ant-...',
model: 'claude-3-5-sonnet-20241022',
topK: 40 // Anthropic-specific option
});
Call Signature
createProvider(
type
,options
):AnyGenerationProvider
Defined in: factory.ts:248
Generic provider factory for generation providers with strong typing. This is the default factory for text generation providers. Returns a narrowed type based on the provider type.
Parameters
type
options
WithApiKey
<OpenAIResponsesOptions
| OpenAIOptions
| GoogleOptions
| AnthropicOptions
>
Returns
Example
// Strongly typed - options are specific to the provider type
const openai = createProvider('openai', {
apiKey: 'sk-...',
model: 'gpt-4o',
temperature: 0.7
});
const anthropic = createProvider('anthropic', {
apiKey: 'sk-ant-...',
model: 'claude-3-5-sonnet-20241022',
topK: 40 // Anthropic-specific option
});