fix: add dialog for vercel ai gateway activation (#1195)

This commit is contained in:
Nico Albanese 2025-09-13 20:40:08 +01:00 committed by GitHub
parent a9c812b5c4
commit 38156eafcf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 68 additions and 5 deletions

View file

@ -242,6 +242,16 @@ export async function POST(request: Request) {
return error.toResponse();
}
// Check for Vercel AI Gateway credit card error
if (
error instanceof Error &&
error.message?.includes(
'AI Gateway requires a valid credit card on file to service requests',
)
) {
return new ChatSDKError('bad_request:activate_gateway').toResponse();
}
console.error('Unhandled error in chat API:', error);
return new ChatSDKError('offline:chat').toResponse();
}