Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,14 @@ export function CreateProviderKeyDialog({
void queryClient.invalidateQueries({ queryKey });
setOpen(false);
},
onError: () => {
onError: (error) => {
setIsValidating(false);
toast({
title: "Validation Failed",
description:
"Failed to validate the API key. Please check your key and region.",
error instanceof Error
? error.message
: "Failed to validate the API key. Please check your key and region.",
variant: "destructive",
});
},
Expand Down
19 changes: 19 additions & 0 deletions packages/actions/src/validate-provider-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,25 @@ export async function validateProviderKey(
};
}

// Treat billing/quota errors as valid key — the key is authenticated
// but the account has insufficient credits or hit rate limits
const isBillingError =
response.status === 402 ||
response.status === 429 ||
errorMessage.toLowerCase().includes("credit balance") ||
errorMessage.toLowerCase().includes("billing") ||
errorMessage.toLowerCase().includes("quota") ||
errorMessage.toLowerCase().includes("rate limit");

if (isBillingError) {
logger.debug("Provider key is valid but has billing/quota issues", {
provider,
model: validationModel,
statusCode: response.status,
});
return { valid: true, model: validationModel };
}

return {
valid: false,
error: errorMessage,
Expand Down
Loading