Classify the failure before retrying
A 4xx validation error may be safe to correct and resubmit. A connection failure or timeout after the request body was sent is ambiguous and must not automatically become a new generation.
| Situation | Recommended action |
|---|---|
| Local validation failed before submission | Correct the request and submit with a new idempotency key. |
| HTTP 202 returned | Persist the task ID, poll the original task and do not submit again. |
| Network timeout without a response | Query the original task or support channel before deciding whether a retry is safe. |
| Terminal provider rejection | Read the structured reason, fix the input if appropriate, and preserve the original receipt. |
Use a stable idempotency key
Generate the key from your application's request identity, not from a random value on every retry. If your client retries the same logical operation, reuse the same key.
Log only what you need
Log the model, status code, request ID, task ID and terminal state. Do not log the bearer token, full private prompts or private media URLs in shared systems.