Errors, usage, and cost control

Understand → practice → verify.

Methods to understand

Distinguish permission errors, rate limits, timeouts, and model-service failures. Retry only recoverable errors with bounded attempts. Record actual usage and enforce per-user limits to prevent endless failure loops.

Apply the method to a scenario

Goal: complete a clearly scoped work task using AI.
Input: public, task-relevant material.
Acceptance: verifiable results and explicitly marked unknowns.

Hands-on workshop

Give failed requests clear states and bounded budgets.

  1. Limit request length, duration, and number of calls.
  2. Distinguish permissions, rate limits, timeouts, and service failure.
  3. Retry only recoverable issues and keep the same task identifier.
const response = await fetch(endpoint, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(input),
  signal: AbortSignal.timeout(15000)
});
if (response.status === 429) {
  // Read Retry-After and resume within the original retry window.
}
if (!response.ok) throw new Error("Request failed: " + response.status);

How to verify

Simulate rate limits and timeouts, check that retries are bounded, and record the actual number of calls for one task.

Practice task

Choose a case related to your work and practice "Errors, usage, and cost control". Submit inputs, steps, results, and verification records.

  • Explain the task goal and inputs
  • Provide actual results or runnable deliverables
  • Identify errors, limits, and verification evidence

Saving a record documents your practice. It does not automatically grant certification.