createProvider static method
Create a provider instance
providerId
- ID of the provider to create
config
- Configuration for the provider
Returns the created provider instance
Throws InvalidRequestError if:
- Provider is not registered
- Configuration is invalid for the provider
Implementation
static ChatCapability createProvider(String providerId, LLMConfig config) {
final factory = getFactory(providerId);
if (factory == null) {
throw InvalidRequestError('Unknown provider: $providerId');
}
if (!factory.validateConfig(config)) {
throw InvalidRequestError(
'Invalid configuration for provider: $providerId');
}
return factory.create(config);
}