Diagnosing Foundation Model API Integration Errors
This lesson catalogues the small number of causes behind integration errors with generative AI services and how error logging, request validation and response analysis reveal them quickly.
Learning outcomes
After completing this lesson, you will be able to:
- Map error codes to their causes.
- Log errors with enough context to diagnose them.
- Analyze responses to find integration problems.
Error codes and their causes
ValidationException (HTTP 400) means the request is invalid: malformed JSON, missing required fields, unsupported parameters for the model, wrong content block types, messages that do not alternate roles or start with a user turn, tool results without matching tool use IDs, input above the context window, or calling a model on demand that requires an inference profile. AccessDeniedException (403) means missing IAM permissions (for example InvokeModelWithResponseStream for streaming), a denying SCP or permissions boundary, a guardrail condition key not satisfied, or a model not available to the account in that Region. ResourceNotFoundException (404) indicates a wrong model ID, ARN or Region.
ThrottlingException (429) means quota exceeded; ModelTimeoutException means generation took too long; ServiceUnavailableException (503) and InternalServerException (500) are transient; ModelNotReadyException means an imported model is starting; ModelErrorException indicates an error in the model's processing of the request.
The following diagram compares the configuration that failed after a model switch with the corrected one that uses a cross-Region inference profile.

Bedrock errors and causes
Error logging, request validation and response analysis
Error logging records, for every failure, the error code and message, the AWS request ID, model ID, operation, Region, input token estimate and the caller, in structured logs that Logs Insights can group by error type. Request validation before calling, for example against a schema for the Converse message structure and a token budget, turns many runtime validation errors into immediate, clear application errors. Response analysis checks every successful response: the stop reason (end_turn, max_tokens, tool_use, stop_sequence, guardrail_intervened, content_filtered), empty content, unexpected formats and token usage.
The following table summarises common integration problems.
| Symptom | Likely cause | Fix |
|---|---|---|
| ValidationException after adding history | Roles not alternating or bad tool result IDs | Validate message structure |
| ValidationException for a new model ID | Model requires an inference profile | Use the inference profile ID or ARN |
| AccessDeniedException only when streaming | Missing InvokeModelWithResponseStream | Add the permission |
| AccessDeniedException with cross-Region profile | Destination Region permissions or SCP | Allow profile and models in all profile Regions |
| Intermittent 429 at peaks | Quota exceeded | Backoff, queues, cross-Region inference, quota increase |
| Responses replaced by a fixed message | Guardrail intervened | Inspect guardrail trace; adjust policy or input |
What to log for each failure
Errors after a model switch
After changing the configured model ID to a newer model, every request fails with ValidationException stating that on-demand throughput is not supported for this model.
The newer model is offered on demand only through a cross-Region inference profile. Updating the configuration to the profile ID (for example with the us. or eu. prefix) and granting IAM permissions on the profile and the model in the profile's Regions fixes the integration.
An AccessDeniedException occurs although the IAM policy allows InvokeModel. What else can deny it?
Show answer
An SCP, a guardrail condition in a policy, or the model not being available to the account.
Exam Tips
Remember for the exam
- ValidationException: fix the request (structure, parameters, length, inference profile).
- AccessDeniedException: IAM, SCPs, guardrail conditions or model availability.
- Retry 429 and 5xx with backoff; never retry 4xx validation errors unchanged.
- Check stop reasons, including guardrail interventions, on every response.