Let’s Get Certified
Module 11 / 21 · Implementation and integration

Keep a model API responsive through failures

Implement streaming, routing and bounded retries around a stable inference interface.

Keep a model API responsive through failures

Work through the decision

A client retries every failed request three times, even when the request body is malformed. Under load it receives more throttling errors. Which errors should it retry?

Check your reasoning

Validate and reject malformed work immediately. Retry transient throttling with bounded exponential backoff and jitter inside the caller's deadline. A stream that already emitted text needs explicit partial-response handling. Route only to models that support the request contract.

Watch the source lesson at 17:02

Compare the choices

Use a provider-neutral adapter
Translate an application contract into supported provider requests, such as a Bedrock Converse message. Validate unsupported features at the edge.
Stream output chunks
Deliver incremental content and handle cancellation and partial failure. Streaming reduces time to first visible output, not necessarily total processing time.
Bound retries with backoff and jitter
Retry eligible temporary failures within a deadline and limit concurrency. Fix validation and authorization errors at their source.
Route using request requirements
Select an approved model using modality, latency, quality, cost and caller constraints before submitting a request.

Use a retry budget

A request has 900 ms remaining. An exponential backoff policy proposes waiting 1,200 ms before the next attempt. Return a recoverable status or route to an eligible fallback inside the deadline. After partial streaming, identify the incomplete message so a retry does not silently append a duplicate.

Apply it on AWS

Converse and ConverseStream provide conversational interfaces across supported Bedrock models. Handle stream events and stop reasons explicitly. A ThrottlingException merits controlled backoff, while a ValidationException needs a corrected request. Verify model capability support before switching routes.

Practice the guide skills

  1. Normalize conversation messages in an adapter and reject options unsupported by the target model. Watch 17:02
  2. Stream partial responses with a cancellation path and a clear outcome when the stream fails after output has started. Watch 2:54:37
  3. Bound retries by deadline, use jitter for transient failures and return validation errors for repair. Test the partial-response case. Watch 2:59:49
  4. Apply modality, quality, geography and caller requirements before ranking eligible models by cost or latency. Watch 3:04:36

Official objectives for this lesson

Related lesson · Choose an AWS delivery model for generative AI

Knowledge check

Keep a model API responsive through failures quiz

Answer 3 questions. Check each answer for an explanation.