Skip to content

AnthropicStream

Namespace: Vercel.AI.Anthropic

public sealed class AnthropicStream

Turns Anthropic SSE JSON events into SDK stream parts.

Inheritance: object

View source

public AnthropicStream(bool includeRawChunks, bool usesJsonResponseTool)

Creates a stream reader.

Parameters

Name Type Description
includeRawChunks bool
usesJsonResponseTool bool

View source

public AnthropicStream(bool includeRawChunks, bool usesJsonResponseTool, string providerOptionsName, bool usedCustomProviderKey)

Creates a stream reader that mirrors the finish metadata under a custom provider key.

Parameters

Name Type Description
includeRawChunks bool
usesJsonResponseTool bool
providerOptionsName string
usedCustomProviderKey bool

View source

public IEnumerable<LanguageModelStreamPart> Complete()

Ends the stream. Returns an interrupted finish part when the events ended cleanly after output without a message_stop for the last message. A stream without output, or with an error, gets no finish part so the existing no-output and error paths apply.

Returns: IEnumerable<LanguageModelStreamPart>

View source

public IEnumerable<LanguageModelStreamPart> Push(string json)

Reads one SSE data payload.

Parameters

Name Type Description
json string

Returns: IEnumerable<LanguageModelStreamPart>

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product