fix: gateway error not showing in ui (#1441)

This commit is contained in:
dancer 2026-03-02 16:01:11 +00:00 committed by GitHub
parent 5c941dd830
commit 49ba1d5f14
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 12 deletions

View file

@ -220,7 +220,17 @@ export async function POST(request: Request) {
});
}
},
onError: () => "Oops, an error occurred!",
onError: (error) => {
if (
error instanceof Error &&
error.message?.includes(
"AI Gateway requires a valid credit card on file to service requests",
)
) {
return "AI Gateway requires a valid credit card on file to service requests. Please visit https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dadd-credit-card to add a card and unlock your free credits.";
}
return "Oops, an error occurred!";
},
});
return createUIMessageStreamResponse({