Skip to content

@chinmaymk/aikit v0.0.40


@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 ​

WithApiKey<OpenAIOptions>

Returns ​

OpenAIProvider

Example ​

typescript
// 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 ​

WithApiKey<AnthropicOptions>

Returns ​

AnthropicProvider

Example ​

typescript
// 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 ​

WithApiKey<GoogleOptions>

Returns ​

GoogleProvider

Example ​

typescript
// 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 ​

OpenAIResponsesProvider

Example ​

typescript
// 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 ​

GenerationProviderType

options ​

WithApiKey<OpenAIResponsesOptions | OpenAIOptions | GoogleOptions | AnthropicOptions>

Returns ​

AnyGenerationProvider

Example ​

typescript
// 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
});

Released under the MIT License.