HttpChatTransport class
A ChatTransport that POSTs the AI SDK chat request as JSON to endpoint and streams back the SSE response.
Cancellation uses AbortableRequest.abortTrigger (package:http >= 1.5):
when abort completes, the in-flight request is aborted. If that happens
before headers arrive, send throws http.RequestAbortedException; if it
happens mid-stream, the same exception is added to the body stream, which
then closes.
- Inheritance
-
- Object
- ChatTransport
- HttpChatTransport
Constructors
-
HttpChatTransport({required Uri endpoint, Client? client, FutureOr<
Map< headers()?, Map<String, String> >String, dynamic> body(ChatRequest request)?})
Properties
-
body
→ Map<
String, dynamic> Function(ChatRequest request)? -
Replaces the default body. The default is
{id, messages, trigger, messageId?, ...extraBody}.final - endpoint → Uri
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ FutureOr<
Map< Function()?String, String> > -
Called per request (e.g. to fetch a fresh auth token); merged over the
defaults, case-insensitively.
ChatRequest.extraHeadersmerge last.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
dispose(
) → void -
Releases any resources held by the transport (e.g. an HTTP client).
Called by ChatController.dispose. Default is a no-op.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reconnect(
String conversationId, {required Future< void> abort}) → Future<ChatResponse?> -
Reattaches to the in-progress response stream of
conversationId, as the AI SDK'sreconnectToStream(used byChatController.resumeStream). Returnsnullwhen there is no active stream or resuming is unsupported (the default). Sameabortcontract as send.inherited -
send(
ChatRequest request, {required Future< void> abort}) → Future<ChatResponse> -
Throws if the request cannot be sent. Returns once headers are available.
Must stop work and close ChatResponse.body when
abortcompletes.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited