400 invalid_request_error
Trigger: Missing required fields, malformed messages, or invalid parameter types in the payload.
Fix: Validate model, messages, max_tokens, and any tools/schema JSON before retrying.
Retry: Retry only after fixing the payload; avoid blind retries.
401 authentication_error
Trigger: Missing Authorization header, malformed bearer token, or invalid API key.
Fix: Verify Authorization: Bearer <YOUR_API_KEY> format and key validity.
Retry: Retry after authentication is fixed.
429 rate_limit_error
Trigger: Request rate, concurrency, or quota usage has hit upstream rate limiting.
Fix: Apply exponential backoff and inspect concurrency, context size, and current quota consumption.
Retry: Use 1s/2s/4s backoff with jitter; reduce concurrency or downgrade workload shape if it persists.
500 internal_error
Trigger: Transient upstream instability, tool execution failure, or internal processing issues.
Fix: Capture request id and a compact context summary, then retry; escalate if failures persist.
Retry: Retry 2-3 times with short delays.