When a generation fails after credits were deducted, Apiway automatically calls try_refund_credits with the same amount and the same source (plan or marketplace) within seconds. You should not need to ask for a refund — the system does it for you.
How automatic refund works
- Apiway deducts credits via
try_deduct_creditsbefore the model runs (so we can't over-allocate capacity). - If the model fails or the post-processing throws, the API handler catches the error and calls
try_refund_creditswithamount: totalCost,from_planandfrom_marketset to match the original deduction. - The failure response returns to the client; the credits counter in the header refreshes within a few seconds.
If the balance still looks wrong
- Refresh the page. The header balance is cached briefly; a hard refresh re-reads the live counter.
- Check the gallery at /app/gallery. If the image is there, the generation succeeded and the deduction is correct.
- Wait 30 seconds and re-check. Most failures are refunded inside that window.
- Email support with the failed request timestamp and your account email if the balance is still wrong after a minute.
Why generations fail
- Heavy queue busy → 503 with retry hint. See heavy queue busy.
- Upload too large → 413. See upload too large.
- Underlying model refused (rare) — Gemini can refuse certain content categories. Try a different phrasing or a different model option.
- Network or timeout — generally retries succeed.