Skip to main content

stream_post

Function stream_post 

Source
pub async fn stream_post(
    client: Arc<Client>,
    request_body: ChatCompletionRequest,
    header_map: HeaderMap,
    url: String,
    cancel_token: Option<CancellationToken>,
) -> Result<impl Stream<Item = Result<ChatCompletionChunk, ReactError>>, ReactError>
Expand description

Send a request with stream: true, returning a parsed SSE chunk stream.

Note: Takes ownership of request_body to avoid lifetime conflicts between references and the async stream.

cancel_token enables aborting the stream: the cancellation signal is checked between each SSE chunk, and iteration stops immediately once cancelled.