AccountCreditsDepletedError
fireworks_ai.errors.AccountCreditsDepletedError
Stack trace
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.") 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
Your Fireworks AI account has used all allocated credits for the billing period.
Log into your Fireworks AI dashboard and purchase additional credits or upgrade your subscription plan.
Billing information on file is invalid or expired, causing credit top-up failures.
Update your payment method in the Fireworks AI account settings to ensure successful credit purchases.
Automated scripts or high-volume requests exhausted credits unexpectedly.
Implement request rate limiting and usage monitoring to control credit consumption and avoid sudden depletion.
Code: broken vs fixed
from fireworks_ai import FireworksClient
client = FireworksClient(api_key=os.environ['FIREWORKS_API_KEY'])
response = client.generate('Hello world') # Raises AccountCreditsDepletedError if no credits 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 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.