How do I handle running out of credits in Python?
import openai
try:
r = client.chat.completions.create(model="supercosmos-flash", messages=msgs)
except openai.APIStatusError as e:
if e.status_code == 402:
notify_team("Clatter Labs credits are used up - top up in Console › Billing › Credits")
raise SystemExit(1)
raise
Don't retry a 402: it fails until credits are added. Better still, check your balance ahead of time (GET /v1/account on the Agent API with an account:read key) and top up before it reaches zero.
Good to know#
- If calls fail unexpectedly, check status.clatterlabs.com before debugging further.
- Every response has an
X-Request-Id; log it so a request can be found later. Why log it - Your key's account is responsible for your end users' text under the Abuse policy. What it means for apps
Still need help?#
- General support: support@clatterlabs.com or team@clatterlabs.xyz
- Infrastructure questions, or permanent deletion of your data (your whole account or one service): infrastructure@clatterlabs.xyz
We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Related articles
Still need help?
Tried the steps above and still stuck? Email us. We usually reply within the first hour, and always within 24 hours. A full support team is with you.
Infrastructure questions, or permanent deletion of your data
infrastructure@clatterlabs.xyzFor deleting your whole account or the data of one service.