AnthropicStream

AnthropicStream has been removed in AI SDK 4.0.

AnthropicStream is part of the legacy Anthropic integration. It is not compatible with the AI SDK 3.1 functions. It is recommended to use the AI SDK Anthropic Provider instead.

It is a utility function that transforms the output from Anthropic's SDK into a ReadableStream. It uses AIStream under the hood, applying a specific parser for the Anthropic's response data structure.

Import

React

import { AnthropicStream } from "ai"

API Signature

Parameters

response:

Response

callbacks?:

AIStreamCallbacksAndOptions
AIStreamCallbacksAndOptions

onStart:

() => Promise<void>

onCompletion:

(completion: string) => Promise<void>

onFinal:

(completion: string) => Promise<void>

onToken:

(token: string) => Promise<void>

Returns

A ReadableStream.