All non-2xx responses from the Knouds API return a JSON body. At minimum it contains error (a human-readable message) and code (a machine-readable constant). Some errors include additional context fields to help you diagnose the problem without guessing.
Error reference
The two distinct 402 responses
Two different situations both return 402, and they require different responses:
INSUFFICIENT_CREDITS — you have a valid plan and the model is accessible, but your credit balance is too low. Go to Settings → Billing and top up your credits.
grant_exhausted — your plan includes a limited trial grant for this model (for example, 1 free lifetime generation on a Free plan) and you have used it all. Topping up credits will not help here. You need to upgrade to a higher plan tier.
If you receive grant_exhausted, adding credits to your account will not resolve the error. The grant is a tier-level feature, not a credit-level one. Upgrade your plan to regain access.
CAPABILITY_DENIED payload
When your key lacks the required capability, the response tells you exactly which one would have passed:
Use required to decide whether to regenerate your key with broader capabilities (capped by your tier) or upgrade your tier.
Handling errors in code