Getting Started with OpenAI Models on Amazon Bedrock
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending
.mdto the page URL.
OpenAI models on Amazon Bedrock expose an OpenAI-compatible Responses API surface for production workflows that need text generation, structured outputs, application tools, direct file inputs, response state, prompt caching, and background work. This cookbook keeps the examples concrete by building a support-assistant workflow for BrightCart, a fictional retailer handling delayed and damaged-order replacement requests.
You will use the OpenAI Python SDK for normal application calls and a small raw HTTPS helper when it is useful to inspect the exact request body. The flow starts with setup and a minimal preflight, then layers on response lifecycle, model controls, structured JSON, application tools, file input, state management, caching, background processing, context compaction, operations checks, and cleanup.
You will learn how to:
- Configure a Bedrock-hosted OpenAI model with Bedrock-specific environment variables.
- Verify the Responses endpoint and inspect response schema, usage metadata, and normalized errors.
- Send text requests with both raw HTTPS and the OpenAI SDK.
- Generate schema-constrained JSON and lighter JSON-mode handoffs.
- Call application-managed function tools, parallel tools, and custom text tools.
- Send a direct PDF input, continue stateful and stateless conversations, and carry encrypted reasoning context.
- Use prompt caching, background mode, compaction, operational smoke checks, and stored-response cleanup.
Prerequisites: a bearer token for OpenAI models on Amazon Bedrock, Python 3.9 or newer, and network access to your Bedrock OpenAI-compatible endpoint.
This guide runs openai.gpt-5.4 in us-west-2 by default. To use another supported pairing, change AWS_REGION, BEDROCK_MODEL, and BEDROCK_BASE_URL together before running the setup cells.
| AWS Region | Supported model IDs |
|---|---|
us-west-2 | openai.gpt-5.4 |
us-east-2 | openai.gpt-5.5, openai.gpt-5.4 |
本篇目录
- 1. Configure Amazon Bedrock
- 2. Make Your First Responses Requests
- 3. Generate Structured JSON
- 4. Add Application-Managed Tools
- 5. Send Direct File Input
- 6. Manage Conversation State
- 7. Use Prompt Caching
- 8. Run Background Work
- 9. Compact Long-Running Context
- 10. Run Operational Smoke Checks
- 11. Clean Up and Review Results