Returns the number of registered providers.
Count of registered providers
Registers an adapter creator for a provider.
Unique identifier for the provider (e.g., 'anthropic')
Factory function that creates adapters for this provider
Registration options
Result indicating success or failure
Unregisters an adapter creator for a provider.
The provider ID to unregister
Result indicating whether the provider was removed
Creates an adapter instance for the specified configuration.
Validates the configuration against the schema, looks up the provider in the registry, and invokes the creator function to produce an adapter.
Adapter configuration specifying provider and settings
Provider identifier (e.g., 'anthropic', 'openai')
Model identifier (e.g., 'claude-sonnet-4', 'gpt-4o')
OptionalapiKey?: stringAPI key for authentication (optional, may come from environment)
OptionalbaseUrl?: stringBase URL for the API (optional, uses provider default)
Optionaltimeout?: numberRequest timeout in milliseconds
OptionalmaxRetries?: numberMaximum number of retries for failed requests
Result containing the adapter or a ConfigError
Checks if a provider is registered.
The provider ID to check
True if the provider is registered
Returns a list of all registered provider IDs.
Array of provider identifiers
Clears all registered providers. Useful for testing or resetting the factory state.
Factory for creating and managing model adapters.
Implements the registry pattern to allow dynamic registration of adapter creators for different model providers. This enables a plugin-style architecture where new providers can be added without modifying core code.
Example