Bedrock models and inference contracts
Foundation models and inference
A foundation model is trained on broad data and can perform multiple tasks without training a separate model for each. Amazon Bedrock provides managed access to models; inference means asking an existing model to produce an output. A fictional shop wants answers about its return policy, not a model that invents policy. Choose a model by language, input modalities, output quality, latency and budget. Compare it against a simpler search or deterministic rule before adding generative AI. Embedding models produce vectors instead of prose. A token is a model-specific unit of text or other input; it is not necessarily a word.
Select a supported contract
Converse provides a common message interface for compatible models; InvokeModel uses model-specific payloads. Streaming variants deliver incremental output. Bedrock also documents additional API families and the bedrock-runtime and bedrock-mantle endpoints; their model support differs. Verify the exact model ID or inference profile, API, Region, modalities, quota, provider terms and account permissions before any authorized call. Cross-Region inference profiles can route requests to other Regions; check all destinations against residency requirements and IAM/SCP restrictions. Do not copy a model ID from an old tutorial without verifying lifecycle. AWS distinguishes the lifecycle policy for models launched on or after September 7, 2026 from the legacy policy. Plan replacement and regression tests before end of life.
Prompt and response contracts
Separate instructions, question and reference data. Ask for a compact answer, source IDs and an explicit abstention when evidence is missing. For supported models, structured outputs can constrain output to a JSON schema; the Converse configuration differs from model-native InvokeModel schemas. A syntactically valid JSON answer can still be false or unauthorized. Validate types, allowed values and business rules after parsing. The following fictional response contract is not an AWS request. A context window constrains input and generated output according to the model; leave room for the response and bound maximum output tokens. Treat truncated responses as incomplete, not successful.
{ "answer": "30 days", "citations": [ "return-v1" ], "abstain": false}Operational boundaries
Measure time to first token, total latency, timeout rate and tokens per request on a representative evaluation set. Use bounded retries with jitter for transient failures; do not retry an authorization failure unchanged. Streaming improves perceived responsiveness but does not guarantee lower total time. Never place secrets in prompts, traces or model logs. Review provider terms, data retention and endpoint behavior before sending any approved data. This chapter uses mock responses only; no SDK call or model access request is necessary.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Bedrock models and inference contracts — knowledge check
Reason about inference contracts, grounded answers and bounded agent actions.
What does an embedding model produce?
Which interface uses a common message contract on supported models?
What must be checked before cross-Region inference?
What does valid structured JSON establish?
What should happen before a model reaches EOL?