diff --git a/src/providers/anthropic/chatComplete.ts b/src/providers/anthropic/chatComplete.ts index 6113ad821..a6ac100e2 100644 --- a/src/providers/anthropic/chatComplete.ts +++ b/src/providers/anthropic/chatComplete.ts @@ -480,6 +480,9 @@ export const AnthropicChatCompleteStreamChunkTransform: ( chunk = chunk.trim(); const parsedChunk: AnthropicChatCompleteStreamResponse = JSON.parse(chunk); + + if (parsedChunk.type === 'error') return 'data: [DONE]\n\n'; + if ( parsedChunk.type === 'content_block_start' && parsedChunk.content_block?.type === 'text' diff --git a/src/providers/google-vertex-ai/chatComplete.ts b/src/providers/google-vertex-ai/chatComplete.ts index 23b0d48fd..e2f8f651c 100644 --- a/src/providers/google-vertex-ai/chatComplete.ts +++ b/src/providers/google-vertex-ai/chatComplete.ts @@ -894,6 +894,8 @@ export const VertexAnthropicChatCompleteStreamChunkTransform: ( const parsedChunk: AnthropicChatCompleteStreamResponse = JSON.parse(chunk); + if (parsedChunk.type === 'error') return 'data: [DONE]\n\n'; + if ( parsedChunk.type === 'content_block_start' && parsedChunk.content_block?.type === 'text'