Failures usually happen when the AI service will not accept the input (a size or length it cannot use, or content it does not allow) or is down for a moment. Short outages are retried for you.
If something fails, your credits come back in full; for work with many steps, the steps that did not finish are returned. The message on the failed item says what to change.