addOpenAITextToSpeechClient method

ServiceCollection addOpenAITextToSpeechClient(
  1. String modelId,
  2. String apiKey, {
  3. OpenAIClientOptions? options,
  4. void configure(
    1. TextToSpeechClientBuilder
    )?,
})

Registers an OpenAITextToSpeechClient and its TextToSpeechClient abstraction as singletons.

Implementation

ServiceCollection addOpenAITextToSpeechClient(
  String modelId,
  String apiKey, {
  OpenAIClientOptions? options,
  void Function(TextToSpeechClientBuilder)? configure,
}) {
  final inner = OpenAITextToSpeechClient(modelId, apiKey, options: options);
  final builder = TextToSpeechClientBuilder(inner);
  configure?.call(builder);
  add(ServiceDescriptor.singleton<TextToSpeechClient>(
    (_) => builder.build(),
  ));
  add(ServiceDescriptor.singleton<OpenAITextToSpeechClient>((_) => inner));
  return this;
}