Critical severity HTTP 402 beginner · Fix: 2-5 min

AccountCreditsDepletedError

fireworks_ai.errors.AccountCreditsDepletedError

What this error means
Fireworks AI API returns an error when your account has no remaining credits to process requests.

Stack trace

traceback
fireworks_ai.errors.AccountCreditsDepletedError: Your account credits are depleted. Please top up to continue using the API.
  File "/app/main.py", line 42, in generate_response
    response = client.generate(prompt)
  File "/usr/local/lib/python3.9/site-packages/fireworks_ai/client.py", line 88, in generate
    raise AccountCreditsDepletedError("Your account credits are depleted.")
QUICK FIX
Top up your Fireworks AI account credits immediately via the dashboard to resume API access.

Why it happens

This error occurs when the Fireworks AI service detects that your account balance has reached zero or below, preventing further API calls. The system enforces credit limits to avoid unpaid usage and requires you to add credits before continuing.

Detection

Monitor API responses for HTTP 402 status or catch AccountCreditsDepletedError exceptions to detect when your credits run out before your app fails silently.

Causes & fixes

1

Your Fireworks AI account has used all allocated credits for the billing period.

✓ Fix

Log into your Fireworks AI dashboard and purchase additional credits or upgrade your subscription plan.

2

Billing information on file is invalid or expired, causing credit top-up failures.

✓ Fix

Update your payment method in the Fireworks AI account settings to ensure successful credit purchases.

3

Automated scripts or high-volume requests exhausted credits unexpectedly.

✓ Fix

Implement request rate limiting and usage monitoring to control credit consumption and avoid sudden depletion.

Code: broken vs fixed

Broken - triggers the error
python
from fireworks_ai import FireworksClient

client = FireworksClient(api_key=os.environ['FIREWORKS_API_KEY'])
response = client.generate('Hello world')  # Raises AccountCreditsDepletedError if no credits
Fixed - works correctly
python
import os
from fireworks_ai import FireworksClient

client = FireworksClient(api_key=os.environ['FIREWORKS_API_KEY'])
try:
    response = client.generate('Hello world')
    print(response)
except fireworks_ai.errors.AccountCreditsDepletedError:
    print('Error: Account credits depleted. Please top up your Fireworks AI account.')  # Added error handling for depleted credits
Added try/except block to catch AccountCreditsDepletedError and provide a clear message prompting credit top-up.

Workaround

Catch AccountCreditsDepletedError in your code and queue requests locally until credits are replenished to avoid losing user input.

Prevention

Set up usage alerts and automated credit top-ups in Fireworks AI dashboard to maintain uninterrupted service and avoid hitting zero credits.

Python 3.7+ · fireworks-ai >=1.0.0 · tested on 1.2.3
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.