OpenAiChatProvider class

Chat provider adapter for OpenAI-compatible chat completions.

Supports non-streaming completions through complete and server-sent event streaming through stream. The provider can be used with OpenAI's chat completions endpoint or compatible APIs that accept the same payload shape.

Inheritance

Constructors

OpenAiChatProvider({String? apiKey, String? bearerToken, Uri? endpoint, AiHttpClient? httpClient})
Creates an OpenAI chat provider using either an API key or bearer token.

Properties

apiKey String?
API key used as a bearer token when bearerToken is not supplied.
final
bearerToken String?
Explicit bearer token. Takes precedence over apiKey.
final
displayName String
Human-readable provider name.
no setteroverride
endpoint Uri
Chat completions endpoint.
final
hashCode int
The hash code for this object.
no setterinherited
httpClient AiHttpClient
HTTP transport used for provider requests.
final
id String
Stable provider id used for registration and lookup.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

complete(ChatRequest request) Future<ChatResult>
Executes a non-streaming completion request.
override
describe() Map<String, dynamic>
Returns a serializable description of the provider.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stream(ChatRequest request) Stream<ChatEvent>
Streams OpenAI-compatible Server-Sent Events.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited