OpenAIProvider class
OpenAI provider implementation.
Supports GPT-4o, GPT-4, GPT-3.5-turbo, and other OpenAI models.
final openai = OpenAIProvider(
config: AIConfig(
apiKey: 'sk-...',
model: 'gpt-4o',
),
);
final response = await openai.complete([
AIMessage.user('Hello!'),
]);
Constructors
- OpenAIProvider({required AIConfig config, Client? httpClient})
Properties
-
capabilities
→ List<
AICapability> -
List of capabilities this provider supports.
no setter
- config → AIConfig
-
The configuration for this provider.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- model → String
-
The current model being used.
no setter
- name → String
-
Human-readable name of this provider.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
complete(
List< AIMessage> messages, {int? maxTokens, double? temperature, List<AITool> ? tools}) → Future<AIResponse> - Sends a completion request and returns the full response.
-
completeStream(
List< AIMessage> messages, {int? maxTokens, double? temperature, List<AITool> ? tools}) → Stream<AIStreamChunk> - Sends a completion request and returns a stream of chunks.
-
dispose(
) → Future< void> - Releases any resources held by this provider.
-
embed(
String text) → Future< List< double> > - Generates embeddings for the given text.
-
estimateTokens(
String text) → int - Estimates the number of tokens in the given text.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
speechToText(
List< int> audioBytes, {String? mimeType, String? language}) → Future<String> - Transcribes spoken audio bytes into text.
-
supports(
AICapability capability) → bool - Whether this provider supports a specific capability.
-
textToSpeech(
String text, {String? voice}) → Future< List< int> > - Synthesizes spoken audio from text.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited