Introduction to FM API Integration Patterns
Calling FMs synchronously and asynchronously, streaming responses in real time, and designing API Gateway interfaces that handle streaming, token limits, timeouts and validation.
- 4 lessons
- Module quiz
Applications call foundation models in three basic ways, and the right one depends on how quickly the result is needed. Synchronous calls wait for the complete response, which suits short tasks in interactive applications. Streaming returns the response token by token as it is generated, so users see the first words within a second even when the full answer takes much longer. Asynchronous processing queues work, through Amazon SQS or Bedrock batch inference, for tasks where nobody is waiting.
Most applications expose their generative AI capabilities through Amazon API Gateway, which brings its own constraints. REST API integrations time out after 29 seconds by default, which long generations can exceed, so designs use streaming, WebSocket APIs or asynchronous job patterns. Token limits must be managed to protect both the model's context window and costs.
What the exam expects
Questions test which errors to retry, such as throttling and server errors with backoff, and which never to retry, such as validation errors; choosing streaming or asynchronous patterns for long generations; and basic efficiency practices such as creating SDK clients outside the Lambda handler so they are reused.
How this module is organised
Invoking Foundation Models Synchronously explains the Bedrock Runtime APIs and request validation. Processing Generative AI Work Asynchronously with SQS and Batch Inference explains queued and bulk processing. Streaming Model Responses to Clients explains the streaming APIs and their considerations, and Designing Foundation Model APIs with API Gateway explains how to handle timeouts, long-running generation and token limits.
- Invoking Foundation Models Synchronously Lesson 1
- Processing Generative AI Work Asynchronously with SQS and Batch Inference Lesson 2
- Streaming Model Responses to Clients Lesson 3
- Designing Foundation Model APIs with API Gateway Lesson 4
- Practise and review
- Checkpoint Practice activities across the module
- Test your knowledge 4 questions