vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid

Home Page:https://sdk.vercel.ai/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ungraceful failure error when the anthropic api is overloaded

TechNickAI opened this issue · comments

Description

When anthropic api is busy/down, it responds with

{"type":"error","error":{"details":null,"type":"overloaded_error","message":"Overloaded"}}

Which causes an unhandled rejection

unhandledRejection: TypeValidationError [AI_TypeValidationError]: Type validation failed: Value: {"type":"error","error":{"details":null,"type":"overloaded_error","message":"Overloaded"}}.
Error message: [
{
"code": "invalid_union_discriminator",
"options": [
"message_start",
"content_block_start",
"content_block_delta",
"content_block_stop",
"message_delta",
"message_stop",
"ping"
],
"path": [
"type"
],
"message": "Invalid discriminator value. Expected 'message_start' | 'content_block_start' | 'content_block_delta' | 'content_block_stop' | 'message_delta' | 'message_stop' | 'ping'"
}
]
at safeValidateTypes (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_d8329a..js:2811:20)
at safeParseJSON (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_d8329a.
.js:2856:16)
... 5 lines matching cause stack trace ...
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
cause: ZodError: [
{
"code": "invalid_union_discriminator",
"options": [
"message_start",
"content_block_start",
"content_block_delta",
"content_block_stop",
"message_delta",
"message_stop",
"ping"
],
"path": [
"type"
],
"message": "Invalid discriminator value. Expected 'message_start' | 'content_block_start' | 'content_block_delta' | 'content_block_stop' | 'message_delta' | 'message_stop' | 'ping'"
}
]
at get error (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_zod_lib_index_mjs_8e7072..js:665:31)
at safeValidateTypes (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_d8329a.
.js:2813:41)
at safeParseJSON (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_d8329a..js:2856:16)
at Object.transform (/Users/nick/src/cora-morphic/.next/server/chunks/ssr/node_modules_d8329a.
.js:3033:40)
at invokePromiseCallback (node:internal/webstreams/util:180:10)
at Object. (node:internal/webstreams/util:185:23)
at transformStreamDefaultControllerPerformTransform (node:internal/webstreams/transformstream:526:37)
at node:internal/webstreams/transformstream:567:16
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
issues: [ [Object] ],
addIssue: [Function (anonymous)],
addIssues: [Function (anonymous)],
errors: [ [Object] ]
},
value: {
type: 'error',
error: { details: null, type: 'overloaded_error', message: 'Overloaded' }
}
}

Code example

No response

Additional context

No response

Same issue faced.

Resolved in @ai-sdk/anthropic@0.0.34