SDK Reference

Error Handling

Implement robust SDK-level error handling and retries.

Handling Pattern

  1. Catch and classify error type.
  2. Retry only transient errors.
  3. Capture request_id/job_id in logs.
  4. Escalate permanent errors to user-facing state.

Sample Error Envelope

{
  "error": {
    "code": "insufficient_credits",
    "message": "Not enough credits to process this video",
    "request_id": "req_123456"
  }
}

Recommended SDK Usage Pattern

  1. Initialize singleton client per service process.
  2. Wrap SDK calls with your own timeout/retry decorators.
  3. Map SDK/domain errors into internal error taxonomy.
  4. Capture job_id and business context in your tracing system.

SDK Hardening Checklist

  • Add per-call timeout defaults and circuit breaking.
  • Track SDK version in logs for post-incident debugging.
  • Test SDK upgrade in staging with archived production payloads.
  • Implement fallback strategy by model and output format.

Error Recovery Flow

  1. Classify error as retriable vs non-retriable.
  2. Apply retry policy with capped attempts.
  3. Escalate with full diagnostic context after budget exhausted.