InsufficientCreditsError
runpod.client.errors.InsufficientCreditsError
Stack trace
runpod.client.errors.InsufficientCreditsError: Insufficient credits to start pod. Please add credits to your account or reduce pod resource requirements.
File "/app/main.py", line 42, in start_pod
pod = client.pods.start(config)
File "/usr/local/lib/python3.9/site-packages/runpod/client/pods.py", line 58, in start
raise InsufficientCreditsError("Insufficient credits to start pod.") Why it happens
RunPod requires sufficient prepaid credits in the user account to allocate and start pods. If the account balance is too low to cover the requested pod's cost, the API rejects the start request with this error. This prevents users from incurring unpaid usage.
Detection
Check the account credit balance via RunPod's API before starting pods, and catch InsufficientCreditsError exceptions to handle low credit scenarios gracefully.
Causes & fixes
User account credit balance is zero or below the required amount for the requested pod.
Add credits to your RunPod account dashboard or via the billing API before attempting to start the pod.
Pod configuration requests more resources (CPU, GPU, RAM) than affordable with current credits.
Reduce pod resource requirements in the configuration to lower the cost below available credits.
Billing or payment method issues causing credits not to be applied or updated.
Verify payment method status and billing settings in the RunPod dashboard to ensure credits are properly applied.
Code: broken vs fixed
from runpod import RunPodClient
client = RunPodClient(api_key='my_api_key') # Hardcoded key - bad practice
config = {'cpu': 4, 'gpu': 1, 'ram': 16}
pod = client.pods.start(config) # Raises InsufficientCreditsError if no credits import os
from runpod import RunPodClient
client = RunPodClient(api_key=os.environ['RUNPOD_API_KEY']) # Use env var for API key
config = {'cpu': 2, 'gpu': 0, 'ram': 8} # Reduced resources to lower cost
try:
pod = client.pods.start(config)
print('Pod started successfully:', pod)
except runpod.client.errors.InsufficientCreditsError:
print('Error: Insufficient credits to start pod. Please add credits or reduce resources.') Workaround
Catch the InsufficientCreditsError exception and prompt the user to add credits or automatically retry with a lower resource pod configuration.
Prevention
Implement a pre-check of account credit balance via RunPod API before pod start requests and enforce resource limits based on available credits to avoid runtime failures.