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

Constructors

HttpChatTransport({required Uri endpoint, Client? client, FutureOr<Map<String, String>> headers()?, Map<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<String, String>> Function()?
Called per request (e.g. to fetch a fresh auth token); merged over the defaults, case-insensitively. ChatRequest.extraHeaders merge 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's reconnectToStream (used by ChatController.resumeStream). Returns null when there is no active stream or resuming is unsupported (the default). Same abort contract 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 abort completes.
override
toString() → String
A string representation of this object.
inherited

Operators

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