diff --git a/src/components/Quilly.tsx b/src/components/Quilly.tsx index 7a8b20e3..88db0970 100644 --- a/src/components/Quilly.tsx +++ b/src/components/Quilly.tsx @@ -118,6 +118,12 @@ export function Quilly({ error, onDismiss, onNewChat, onOpenModelSelector, onReq }], }; + case 'key_limit_exceeded': + return { + message: `It seems your API key has been used up. Check your API provider's settings, or try a different API key or different provider/model combo`, + actions: [], + }; + case 'bad_request': return { message: 'The AI provider did not understand the message / data it got. If it persists, try stating a new conversation or using a different model.', diff --git a/src/lib/SessionManager.ts b/src/lib/SessionManager.ts index 2d30daef..b375e1a4 100644 --- a/src/lib/SessionManager.ts +++ b/src/lib/SessionManager.ts @@ -419,6 +419,16 @@ export class SessionManager { apiError.code = code; throw apiError; } + if (error?.status === 403) { + const code = 'key_limit_exceeded'; + const apiError = new OpenAI.APIError({ + status: error.status, + code, + message: `${error.status} Provider returned error` + }); + apiError.code = code; + throw apiError; + } if (error?.status === 422) { const code = 'unprocessable_entity' const apiError = new OpenAI.APIError({