AIP-C01 FM API Integrations: Bedrock Sync and Async Calls, Streaming, Resilience and Model Routing
Foundation model API integration is the application code and AWS plumbing that calls Amazon Bedrock models reliably: synchronous SDK calls from any compute, asynchronous processing through Amazon SQS and Bedrock's async APIs, token streaming to users, retries and fallbacks under throttling, and routing each request to the right model. Task 2.4 of the AWS Certified Generative AI Developer – Professional exam tests these patterns in production scenarios, where one stated constraint (no Lambda, keep the REST API, a latency budget, least custom code) decides between designs that would all work.
On this page10 sections
- What does AIP-C01 Task 2.4 cover?
- Calling Bedrock synchronously from any compute
- Asynchronous processing: SQS buffering and Bedrock's async APIs
- API Gateway as the custom API: request validation and client SDKs
- Streaming FM responses with ConverseStream
- Delivering the stream to clients: SSE, WebSockets and API Gateway
- Retries, exponential backoff and retryable Bedrock errors
- Rate limiting with API Gateway and graceful fallbacks
- Tracing FM calls across services with AWS X-Ray
- Model routing: static, content-based, metric-based and at the API edge
- Call Bedrock synchronously from Lambda, ECS, EKS and on-premises servers with the right credentials and SDK timeouts
- Choose between SQS-buffered consumers, StartAsyncInvoke and batch inference for asynchronous FM work, and tune event source mappings so throttling never re-bills or loses messages
- Use API Gateway REST API request validators, gateway responses and generated SDKs to give clients a governed FM API
- Stream FM output with ConverseStream through Lambda response streaming, REST API response streaming or WebSocket APIs, including tool-use events and errors that arrive after HTTP 200
- Design retries, rate limits and fallbacks that keep an FM application inside its latency and cost budget, and trace requests end to end with X-Ray and OpenTelemetry
- Pick static, content-based, metric-based or API-edge model routing for a scenario and implement it on Converse, Step Functions, CloudWatch metrics or API Gateway mapping templates
What does AIP-C01 Task 2.4 cover?
Task 2.4 covers how application code talks to foundation models (FMs) reliably: calling Amazon Bedrock synchronously and asynchronously from any compute, streaming tokens to users in real time, surviving throttling and outages, and choosing which model serves each request. It has four official skills:
- 2.4.1 Flexible model interaction: Bedrock APIs called synchronously from Lambda, containers, Kubernetes or on-premises servers through the language SDKs; Amazon SQS for asynchronous processing; Amazon API Gateway as the custom API that validates requests and serves client SDKs.
- 2.4.2 Real-time interaction: Bedrock streaming APIs, WebSockets or server-sent events, and API Gateway response streaming (chunked transfer).
- 2.4.3 Resilience: SDK exponential backoff, API Gateway rate limiting, fallbacks for graceful degradation, and AWS X-Ray tracing across service boundaries.
- 2.4.4 Model routing: static routing in application code, Step Functions content-based routing, routing on observed metrics, and API Gateway request transformations.
Neighbouring topics own related material, so this lesson only points at them: agents and tool frameworks (Task 2.1), deployment choices such as Provisioned Throughput (Task 2.2), enterprise gateways and legacy integration (Task 2.3), and developer tooling (Task 2.5). Cross-Region inference, prompt routers and circuit breakers belong to the design topics in Domain 1. They appear in Task 2.4 scenarios mainly as alternatives that miss a stated requirement.
Calling Bedrock synchronously from any compute
A synchronous call sends a request through an AWS SDK (bedrock-runtime client) and blocks until the whole answer is returned. Two things decide whether it works in production: the caller's credentials and the client's timeouts.
Converse or InvokeModel
Converse takes one request shape for every message-capable model (messages, system, inferenceConfig, toolConfig) and returns one response shape. InvokeModel takes each provider's native JSON body, so changing provider means changing code. Converse is what lets a model swap become a configuration change.
Credentials per compute environment
| Where the code runs | Where Bedrock permissions go | Common mistake |
|---|---|---|
| Lambda | The function's execution role | Hard-coded access keys in environment variables |
| ECS (EC2 or Fargate) | The task role (taskRoleArn) | Adding it to the task execution role, which only serves the ECS agent (image pulls, logs) |
| EKS pods | An EKS Pod Identity association (or IRSA) for the workload's service account | Granting the node group role, which every pod on the node can use |
| On-premises servers with X.509 certificates | IAM Roles Anywhere: the private CA as a trust anchor, mapped to a role | IAM users with long-term keys and a rotation job |
| End-user apps (browser, mobile) | An Amazon Cognito identity pool, or better, your own API in front of Bedrock | Using an identity pool for server workloads |
An AccessDeniedException from a container that otherwise works normally (pulls images, writes logs) usually means the permission sits on the wrong role.
Client timeouts
Long generations can outlast the SDK's defaults. In boto3 (Python), the socket read_timeout in botocore.config.Config defaults to about one minute, so a long report can fail with a read timeout even when the Lambda function still has minutes left. Raise the read timeout on the client. Raising the function timeout or the retry count doesn't help, because each retry hits the same limit and pays for the generation again.
The AWS SDK for Java 2.x separates the two budgets clearly:
apiCallAttemptTimeoutcaps one HTTP attempt, so a slow attempt is abandoned and can be retried.apiCallTimeoutcaps the whole call, including every retry and backoff wait, so the service gets control back in time to serve a fallback.- The HTTP client's connection timeout only limits opening the TCP connection. The socket timeout limits the gap between received bytes. Neither caps total duration.
Asynchronous processing: SQS buffering and Bedrock's async APIs
Use asynchronous processing when nobody waits on the answer in the same request. Either buffer the work in Amazon SQS and let a consumer call the model at a controlled rate, or hand the job to Bedrock's own asynchronous APIs.
SQS → Lambda → Bedrock
- Cap the consumer with the event source mapping's maximum concurrency, not reserved concurrency. Maximum concurrency stops the poller from starting more invocations, so extra messages simply wait in the queue. With reserved concurrency alone, the poller keeps delivering batches, throttled invocations return messages to the queue, each attempt counts as a receive, and messages can reach the dead-letter queue (DLQ) without ever being processed.
- Visibility timeout of at least six times the function timeout (AWS's recommendation for SQS-triggered Lambda). If a long translation outlasts the visibility timeout, the message reappears and a second invocation processes it, so the model is billed twice. Long polling and FIFO deduplication IDs don't prevent this.
- Partial batch responses. Turn on
ReportBatchItemFailuresin the mapping's function response types and return failed message IDs inbatchItemFailures. Only those messages return to the queue. Without it, one throttled call returns the whole batch and the successful items are sent to the model again. - The redrive policy's maximum receive count decides when a repeatedly failing message moves to the DLQ. Batch size changes the number of messages per invocation, not how many invocations run at once.
Bedrock's own asynchronous paths
| Need | API | Notes |
|---|---|---|
| A user is waiting for an interactive answer | Converse / InvokeModel (or the streaming variants) | On-demand pricing |
| One long generation, such as a video from Amazon Nova Reel | StartAsyncInvoke, then GetAsyncInvoke (or ListAsyncInvokes) | Returns an invocation ARN immediately and writes output to the S3 location you give. Only for models that support it. |
| Thousands of offline records already in S3 | Batch inference: CreateModelInvocationJob | Reads JSONL records from S3 and writes results to S3. For supported models it costs less than on-demand. It has minimum record counts and usually finishes within about a day, with no guaranteed time. |
Calling StartAsyncInvoke once per record is not batch processing and gets no batch discount. A batch job per single user request misuses a bulk path. Provisioned Throughput (Task 2.2) is committed capacity for steady high volume and costs more than a batch job for a weekly run.
API Gateway as the custom API: request validation and client SDKs
Put Amazon API Gateway in front of the model when clients need a stable, governed API instead of direct Bedrock access. Several of the features this skill names exist only on REST APIs, so the REST vs HTTP API choice decides the outcome.
| Capability | REST API | HTTP API |
|---|---|---|
| Validate the body against a JSON schema and return 400 before the integration runs | Yes: a model plus a request validator | No |
| Generate client SDKs (Java, JavaScript, Android, iOS and others) from a stage | Yes | No |
| Usage plans and API keys (per-client throttling and quotas) | Yes | No |
Response streaming (responseTransferMode STREAM) | Yes, on proxy integrations | No |
| AWS service integration with VTL mapping templates (call Bedrock with no Lambda) | Yes | No (parameter mapping only changes headers, query strings and paths) |
| JWT authorizers | Through Cognito user pool authorizers | Yes, native |
Authorizers check identity, not request bodies. A Lambda authorizer doesn't receive the body on either API type, and a JWT authorizer checks tokens and scopes. Moving schema checks into an authorizer or into the function means custom code that a request validator makes unnecessary.
By default a validation failure returns a generic Invalid request body message. To tell callers which field failed without writing code, customize the BAD_REQUEST_BODY gateway response to include $context.error.validationErrorString. ($context.error.message only carries the generic text.)
When partners want ready-made client libraries but all traffic must still pass through your API, generate SDKs from the deployed REST API stage. Handing out the AWS SDK and IAM credentials bypasses the API entirely.
Streaming FM responses with ConverseStream
Streaming returns the answer as an event stream while the model generates it, so the first words appear in a second or two instead of after the full generation. ConverseStream streams in the unified Converse format. InvokeModelWithResponseStream streams each provider's native chunks. Shorter maxTokens, caching or latency-optimized inference may speed things up, but without streaming the user still sees nothing until the answer is complete.
The event sequence
messageStart: the role of the reply.contentBlockStart: opens a block. For a tool call it carries thetoolUsename andtoolUseId.contentBlockDelta: incremental content, eitherdelta.textfor text or a fragment of the tool input JSON string for a tool call.contentBlockStop: the block is complete.messageStop: carriesstopReason(for exampleend_turn,max_tokens,tool_use).metadata: carriesusage(input, output and total tokens) andmetrics(latency). Exact per-reply token counts come from here, not frommessageStop, not from counting deltas (a delta isn't one token) and not fromCountTokens, which counts input tokens only (no output tokens) and needs a separate call.
Streaming with tools
Tool input arrives as partial JSON strings spread across several deltas. Concatenate them until contentBlockStop and only then parse. When messageStop reports tool_use, the model is waiting for you: run the tool and send a toolResult block in the next request. A relay that only forwards delta.text drops tool calls silently.
Errors after HTTP 200
A stream returns HTTP 200 as soon as it opens. Later failures arrive as exception events inside the stream (internalServerException, modelStreamErrorException, serviceUnavailableException, throttlingException, validationException), and the SDK raises them while you iterate. Wrap the iteration loop too, not just the initial call, and start any fallback from there. SDK retries apply to the initial request only. A stream that has already delivered events is never replayed.
Delivering the stream to clients: SSE, WebSockets and API Gateway
The delivery path must not buffer what Bedrock streams. Which path fits depends on whether the client only receives or also needs to send messages mid-answer.
| Path | Direction | Key facts |
|---|---|---|
Lambda response streaming (function URL or InvokeWithResponseStream), often as server-sent events | Server → client | The function URL's invoke mode must be RESPONSE_STREAM. In BUFFERED mode it returns everything at once, even if the handler streams. Native on Node.js managed runtimes (awslambda.streamifyResponse). For Python and other runtimes, use a custom runtime or the Lambda Web Adapter with a web framework that streams. |
| API Gateway REST API response streaming | Server → client | Set the integration's responseTransferMode to STREAM. Works with Lambda proxy and HTTP proxy integrations only. A stream can run up to 15 minutes (subject to idle timeouts), so it isn't bound by the default 29-second integration timeout. Not supported with streaming: endpoint caching, content encoding (compression) and VTL response transformation. |
| API Gateway WebSocket API | Both ways | The backend pushes each chunk with PostToConnection on the @connections API. The client can send Stop or follow-up questions over the same connection. |
| Polling an HTTP endpoint | Client pulls | Extra requests and delay. Not real-time streaming. |
A few details decide many real designs:
- Moving a streamed REST method off caching or VTL envelopes means doing that work in the backend: build the response envelope in the function, and cache behind the API. A non-proxy integration can't stream.
- CloudFront in front of a function URL can't stream a response that the function returns in one piece. Fix the source first.
- With WebSockets, a
GoneExceptionfromPostToConnectionmeans the client has left. End the ConverseStream loop right away, because output tokens are billed until generation stops. A$disconnecthandler that only updates a table doesn't stop a generation already running in another invocation.
Retries, exponential backoff and retryable Bedrock errors
Exponential backoff with jitter is the AWS SDKs' built-in answer to transient failures. Each retry waits a random time up to a cap that grows with every attempt, so clients spread out instead of retrying in step. The SDKs offer three retry modes:
| Mode | Behaviour | Fits |
|---|---|---|
| Legacy | Older, SDK-specific behaviour with no standardized retry quota | Backward compatibility only |
| Standard | Exponential backoff with jitter, plus a retry quota that stops retry storms when many attempts are failing | The usual default, and shared clients that serve many models or tenants |
| Adaptive | Standard behaviour plus a client-side rate limiter that slows even first attempts after throttling | One client calling one resource at high volume with no latency target, such as a nightly batch |
The adaptive rate limiter applies to the whole client instance. If one shared client serves many models, one throttled model slows every request it sends. Use standard mode there, or a separate adaptive client per model. Adaptive mode also delays first attempts, which hurts latency-sensitive paths. Default attempt counts differ by SDK and version, so set max_attempts explicitly instead of relying on a remembered number.
Custom retry loops (for example, around a non-SDK HTTP signer) need jitter too. A fixed doubling schedule, short fixed delays or a fixed start delay all keep clients synchronized, so throttles arrive in waves. Adding attempts on the same schedule extends the waves.
Retry in one layer. Retries multiply across layers: an app that retries 3 times, calling a function that loops 3 times around an SDK making 3 attempts, can send 27 or more model requests for one user action, right when the model is throttling. Keep the SDK's backoff as the single retry layer, remove extra loops, and have clients fail fast on 429 responses. Moving a loop into Step Functions Retry fields relocates the layer without removing it.
Which Bedrock errors to retry
Retry or fail over only on errors that can succeed later or elsewhere: throttling and server-side faults. A request that's wrong fails the same way on every attempt and on every model, so retrying it doubles the cost and still fails.
| Exception | Meaning | Action |
|---|---|---|
ThrottlingException (429) | The account exceeded the model's request or token quota | Back off and retry, or fail over to another model with its own quota |
ServiceUnavailableException (503), InternalServerException (500) | Transient service-side failure | Retry with backoff, or fail over |
ModelNotReadyException | The model isn't ready to serve yet | The SDK retries it automatically |
ValidationException (400) | Malformed body or invalid parameters | Fix the request. Never retry. |
AccessDeniedException | Missing permission or model access | Fix the configuration |
ResourceNotFoundException | Wrong model ID or ARN | Fix the configuration |
ServiceQuotaExceededException (400) | The request exceeds a service quota | Change the request or the quota. Blind retries won't help. |
Rate limiting with API Gateway and graceful fallbacks
API Gateway rate limiting protects the shared model quota from any single caller and returns 429 Too Many Requests before a request reaches the backend. The limits sit in layers, and the exam scenarios turn on which layer is per-client:
| Control | Applies to | Use it for |
|---|---|---|
| Account-level throttling | All APIs in the account and Region | A ceiling, not a per-client limit |
| Stage and method default throttling | All callers of the stage or method combined | Protecting the backend overall. One busy caller can still use the whole allowance. |
| Usage plan + API keys | Each API key separately (rate, burst and an optional quota) | Per-partner or per-tier limits on a REST API |
| Method throttle override inside a usage plan | Each API key, on one method | A tighter limit on an expensive model method (such as POST /draft) while cheap methods keep the plan limit |
| AWS WAF rate-based rule | Each source IP (or other aggregation key) | Abuse from addresses, not partner contracts |
A quota (requests per day, week or month) is not a rate: it doesn't stop a burst. Lambda reserved concurrency caps the function for everyone together and knows nothing about API keys. A Lambda authorizer that counts requests in DynamoDB can enforce per-key limits, but it adds custom code and a database call to every request, which usage plans already make unnecessary. API keys identify callers for usage plans. Pair them with a real authorizer for authentication.
Fallbacks within a latency budget
A fallback only helps if it gets time to run. With default retry settings, the SDK's throttling backoff can spend a whole response-time budget (say 5 seconds) before the code ever reaches the secondary model. Cap the attempts and per-attempt timeout used for the primary call so that its worst case leaves time for the fallback model to answer. Size the total retry budget to the response-time target, not the other way round.
When the AI output is optional (a personalised greeting on a dashboard, say), the cheapest graceful degradation is non-AI content: after a bounded retry, show static or cached text instead. Buying Provisioned Throughput (Task 2.2) or adding cross-Region capacity (Domain 1) can reduce throttling, but neither gives the page a path when the call still fails. A latency target needs a bounded retry and a fallback either way.
Tracing FM calls across services with AWS X-Ray
A distributed trace shows one request's path through API Gateway, Lambda and the Bedrock call, with each hop's duration, so you can tell whether the time goes to the API, your code or the model. Three pieces build it:
- Enable X-Ray tracing on the API Gateway stage, so the trace starts at the API and context passes to Lambda.
- Enable active tracing on the Lambda function, which records the function's segment.
- Instrument the SDK client inside the function, so each Bedrock call appears as its own subsegment. AWS now recommends OpenTelemetry for this: the AWS Distro for OpenTelemetry (ADOT) or the AWS Lambda layer for OpenTelemetry, which auto-instruments the AWS SDK. The X-Ray SDKs and daemon are in maintenance mode (security fixes only) and are heading for end of support, so new instrumentation should use OpenTelemetry.
Annotations vs metadata. X-Ray indexes annotations, so filter expressions such as annotation.feature = "summaries" can search them. Metadata is stored but not searchable. OpenTelemetry span attributes become X-Ray metadata by default. To filter by one, list its key in aws.xray.annotations so the exporter writes it as an annotation. Sampling decides which traces are recorded, not which fields are indexed.
The other signals answer different questions. CloudTrail is an audit record of who called which API. Bedrock model invocation logs hold prompts and responses for the model call only. CloudWatch Logs Insights queries logs per log group. None of them joins the hops of one request with their timings.
Model routing: static, content-based, metric-based and at the API edge
Model routing decides which FM serves each request. Pick the simplest router that the request already allows: if the request type already names the model, a lookup table is enough.
| Approach | Decides on | Fits when |
|---|---|---|
| Static routing table in code or config | The request type the caller states | The best model per task is settled and changes only at releases. It's deterministic, adds no extra call and has nothing to operate. |
| Step Functions content-based routing | A classification of the content itself | The category isn't known until a model reads the input, and routing should be a visual, configured workflow |
| Metrics-based routing | Observed CloudWatch metrics per model | Two or more models are interchangeable in quality, but their latency or availability varies |
| API Gateway request transformation | The API path or method | Each endpoint maps to one model, and no Lambda should sit in the path |
| Bedrock prompt router (Domain 1) | Predicted response quality and cost per prompt | Choosing between two models of the same family. Not for business categories or mixing providers. |
Static routing that stays a table edit
Build the routing table on Converse, so the model ID is the only thing that changes between models. With InvokeModel (streaming or not), each new provider needs new body-building code. For per-feature cost reporting, create an application inference profile per feature from the model, tag it with the feature (an activated cost allocation tag), and put the profile's ARN in the table as the modelId. Each feature then gets its own costed resource even when two features share a base model. requestMetadata only labels model invocation logs for filtering. Bedrock can also allocate cost by IAM principal, but that can't separate features that share one execution role. System-defined cross-Region inference profiles can't be created per feature, though an application profile can be built on one.
Step Functions content-based routing
A Bedrock InvokeModel task (the optimized integration) classifies the request, and a Choice state branches on the result to a task that calls the specialist model. Model output is text: if the model replies with JSON, that JSON is a string inside the response body (for Anthropic Claude, Body.content[0].text). Parse it with States.StringToJson in a ResultSelector before the Choice state compares a field. Otherwise every execution falls to the Default branch. For short, high-volume routing that must answer in the same HTTP response, use an Express workflow started with StartSyncExecution (synchronous, billed per request and by duration). Standard workflows can't be started synchronously, bill per state transition and suit long-running, auditable processes.
Routing on metrics AWS already collects
Bedrock publishes metrics to CloudWatch in the AWS/Bedrock namespace by ModelId, including Invocations, InvocationLatency, InvocationThrottles, InvocationServerErrors, InvocationClientErrors and token counts such as OutputTokenCount. A scheduled function can read, for example, the p90 latency every few minutes and store the preferred model where the router reads it. To decide on failover, watch throttles and server errors. Ignore client errors: a malformed request would fail on any model, so counting them causes false failovers. Route 53 latency routing compares network latency to Regions, not inference latency between models.
Routing and transforming at the API edge
A REST API AWS service integration can call Bedrock directly with an IAM role. A path override (such as model/{modelId}/invoke) selects the model per method, and a VTL mapping template reshapes a simple client body into that model's request body. HTTP proxy integrations don't sign requests with SigV4 and pass bodies through unchanged. HTTP API parameter mapping can't rebuild a JSON body. When a template inserts user text into JSON, use $input.json('$.body'), which emits a correctly escaped JSON string. $util.escapeJavaScript turns an apostrophe into \', which is invalid JSON and fails with a ValidationException. URL or Base64 encoding produces valid JSON but sends the model the wrong text.
Tip. Task 2.4 questions describe a GenAI application already running on AWS that has one production problem: a timeout on long answers, throttling that spreads to other tenants, a spinner that hides streamed text, duplicate model charges from a queue, tool calls lost in a stream, a partner using up the shared model quota, or a trace that can't show where time goes. Several options are real AWS patterns, and the deciding detail is a stated constraint, such as keeping the REST API, using no Lambda function, the least custom code, a fixed latency budget, no reserved capacity, or exact rather than estimated numbers. Expect to tell apart near-twins: task role vs execution role, maximum vs reserved concurrency, StartAsyncInvoke vs batch inference, REST vs HTTP API features, messageStop vs metadata, standard vs adaptive retries, stage vs usage-plan throttling, annotations vs metadata, and Express vs Standard workflows. Multiple-response items ask for the two settings that together satisfy every requirement.
- A long Bedrock call that fails at about a minute usually hit the SDK read timeout, so raise it on the client. In Java, apiCallAttemptTimeout caps one attempt and apiCallTimeout caps the whole call with retries.
- Container code uses the ECS task role, EKS workloads use Pod Identity on their service account, and on-premises servers with certificates use IAM Roles Anywhere.
- For SQS → Lambda → Bedrock, cap the event source mapping's maximum concurrency, set visibility to at least six times the function timeout, and return batchItemFailures.
- Use StartAsyncInvoke for one long generation written to S3, batch inference for many offline S3 records at a lower price, and on-demand calls for live traffic.
- Request validation, SDK generation, usage plans, response streaming and VTL AWS integrations are REST API features. HTTP APIs have none of them.
- ConverseStream sends text in contentBlockDelta, stopReason in messageStop and token usage in metadata. Tool input arrives in fragments, and errors can arrive after HTTP 200.
- Streaming to a browser needs an unbuffered path: a RESPONSE_STREAM function URL, REST STREAM mode (proxy only, no cache, compression or VTL) or a WebSocket API when the client must talk back.
- Retry throttling and 5xx errors with jittered backoff in one layer only, never validation or access errors. Adaptive mode limits the whole client instance.
- Per-client rate limits are usage plans with API keys, with method overrides for expensive model routes. Stage throttling is shared by every caller.
- Route with a static Converse-based table when the task names the model, Step Functions plus a Choice state when content decides, and CloudWatch throttles, server errors and latency when interchangeable models vary.
Frequently asked questions
What is the difference between ConverseStream and InvokeModelWithResponseStream?
Both stream an Amazon Bedrock model's output as it is generated. ConverseStream uses one request and event format for every message-capable model (contentBlockDelta, messageStop, metadata), so switching models doesn't change code. InvokeModelWithResponseStream takes and returns each provider's native format, so every provider needs its own parsing code.
Where do I get token usage for a streamed Bedrock reply?
Read the metadata event at the end of a ConverseStream response. It carries the usage object (input, output and total tokens) and latency metrics for that reply. The messageStop event carries only the stop reason, and counting delta events gives an estimate, not exact tokens.
Should I use a WebSocket API or server-sent events to stream FM output?
Use server-sent events (for example, a Lambda function URL in RESPONSE_STREAM mode or a REST API in STREAM mode) when text only flows from server to client. Use an API Gateway WebSocket API when the client must also send messages during an answer, such as a Stop button or follow-up questions over the same connection.
Can I stream a Bedrock response from a Python Lambda function?
Not natively on the managed Python runtime: Lambda response streaming is native on Node.js managed runtimes. For Python, AWS points to the Lambda Web Adapter with a Python web framework that streams, or to a custom runtime. Either way, the function URL's invoke mode must be RESPONSE_STREAM.
What limitations does API Gateway REST API response streaming have?
REST API response streaming (responseTransferMode STREAM) works only with Lambda proxy and HTTP proxy integrations. Streamed methods can't use endpoint caching, content encoding or VTL response transformation. A stream can run for up to 15 minutes, subject to idle timeouts, so it isn't limited by the default 29-second integration timeout.
When should I use adaptive retry mode for Amazon Bedrock calls?
Use adaptive mode when one SDK client sends high volumes to one model and latency doesn't matter, such as a nightly batch: it adds a client-side rate limiter that slows requests after throttling. Avoid it on a shared client that serves many models or tenants, because the limiter slows every request from that client instance. Use standard mode there.
Which Bedrock errors should trigger a retry or a fallback model?
Retry or fail over on ThrottlingException and on transient server errors such as ServiceUnavailableException and InternalServerException. Don't retry ValidationException, AccessDeniedException or ResourceNotFoundException: they fail the same way every time and need a fix to the request or configuration.
How do I split Amazon Bedrock costs by application feature?
Create an application inference profile for each feature from its model, tag each profile with the feature as an activated cost allocation tag, and send that feature's requests with the profile ARN as the modelId. Cost Explorer then shows each feature separately, even when features share a base model or an IAM role.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.