Repository Public
1# OpenAI models in Amazon Bedrock23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45Amazon Bedrock runs supported OpenAI models on AWS-managed infrastructure.6Use this guide to compare [OpenAI API feature support](#responses-api-feature-availability)7and connect with the OpenAI SDK. For deployment configuration, use the8[AWS documentation](#availability-and-operations) linked from this page.910Model capabilities and API compatibility determine what your application can11 do. AWS manages model access, regional availability, routing, billing, and12 operational controls for your Bedrock deployment.1314## How Bedrock availability works1516OpenAI models are available through two Amazon Bedrock endpoints:17`bedrock-runtime` and `bedrock-mantle`. Both support the OpenAI-compatible18Responses and Chat Completions APIs for supported models, but their feature19coverage differs.2021Choose your endpoint based on the capabilities your application needs. For22example, hosted web search currently requires Mantle. See the23[endpoint differences](#endpoint-differences) on this page and the AWS [endpoint comparison](https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints.html) for Bedrock-specific capabilities and endpoint selection.2425GPT-6 Astra is available through Bedrock Runtime and through Mantle in26 `us-west-2` (Oregon). The examples in this guide use GPT-5.6 Sol in27 `us-east-2`; select Astra's supported Region before changing the model.2829For access and setup, see the AWS [GPT-6 Astra announcement](https://aws.amazon.com/blogs/machine-learning/take-on-your-most-ambitious-work-with-gpt-6-astra-on-amazon-bedrock/) and [Runtime endpoint instructions](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html).3031## Make Responses API requests3233These examples use the OpenAI SDK with the Mantle endpoint. Select the AWS34Region and model ID for your deployment:3536- Client libraries with a Bedrock provider derive a regional Mantle base URL37 from the AWS Region. The JavaScript, Python, Go, and Java providers use38 `https://bedrock-mantle.us-east-2.api.aws/openai/v1` for this guide's39 `us-east-2` examples. The Ruby examples configure this `/openai/v1`40 endpoint directly because the provider's default `/v1` route doesn't41 support this model.42- Use a Bedrock model ID with the `openai.` prefix, such as43 `openai.gpt-5.6-sol`.4445The examples use `openai.gpt-5.6-sol` in `us-east-2`. For Runtime, follow the AWS [Responses API endpoint instructions](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html) to select the base URL and inference profile. Do not reuse a Mantle model ID46without checking the Runtime requirements.4748The following example uses a Bedrock API key stored as49`AWS_BEARER_TOKEN_BEDROCK`. See [Amazon Bedrock API keys](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html) for information about generating and using a Bedrock API key.5051Install the optional Java Bedrock provider before using either Java example:5253```xml54<dependency>55 <groupId>com.openai</groupId>56 <artifactId>openai-java-bedrock</artifactId>57 <version>4.57.0</version>58</dependency>59```6061Send a Responses API request through Amazon Bedrock6263```javascript64import OpenAI from "openai";65import { bedrock } from "openai/providers/bedrock";6667const client = new OpenAI({68 provider: bedrock({69 region: "us-east-2",70 apiKey: process.env.AWS_BEARER_TOKEN_BEDROCK,71 }),72});7374const response = await client.responses.create({75 model: "openai.gpt-5.6-sol",76 input: "Write a haiku about cloud infrastructure.",77});7879console.log(response.output_text);80```8182```python83import os8485from openai import OpenAI86from openai.providers import bedrock8788client = OpenAI(89 provider=bedrock(90 region="us-east-2",91 api_key=os.environ["AWS_BEARER_TOKEN_BEDROCK"],92 )93)9495response = client.responses.create(96 model="openai.gpt-5.6-sol",97 input="Write a haiku about cloud infrastructure.",98)99100print(response.output_text)101```102103```go104package main105106import (107 "context"108 "fmt"109 "os"110111 "github.com/openai/openai-go/v3"112 "github.com/openai/openai-go/v3/bedrock"113 "github.com/openai/openai-go/v3/responses"114)115116func main() {117 client, err := bedrock.NewClient(context.Background(), bedrock.Config{118 AWSRegion: "us-east-2",119 APIKey: os.Getenv("AWS_BEARER_TOKEN_BEDROCK"),120 })121 if err != nil {122 panic(err)123 }124125 response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{126 Model: "openai.gpt-5.6-sol",127 Input: responses.ResponseNewParamsInputUnion{128 OfString: openai.String("Write a haiku about cloud infrastructure."),129 },130 })131 if err != nil {132 panic(err)133 }134 fmt.Println(response.OutputText())135}136```137138```java139import com.openai.client.OpenAIClient;140import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;141import com.openai.models.responses.ResponseCreateParams;142143public final class AmazonBedrockCreateResponseExample {144 private AmazonBedrockCreateResponseExample() {}145146 public static void main(String[] args) {147 OpenAIClient client =148 BedrockOpenAIOkHttpClient.builder()149 .awsRegion("us-east-2")150 .apiKey(System.getenv("AWS_BEARER_TOKEN_BEDROCK"))151 .build();152153 ResponseCreateParams params =154 ResponseCreateParams.builder()155 .model("openai.gpt-5.6-sol")156 .input("Write a haiku about cloud infrastructure.")157 .build();158159 client.responses().create(params).output().stream()160 .flatMap(item -> item.message().stream())161 .flatMap(message -> message.content().stream())162 .flatMap(content -> content.outputText().stream())163 .forEach(text -> System.out.println(text.text()));164 }165}166```167168```csharp169using System.ClientModel;170using OpenAI.Responses;171#pragma warning disable OPENAI001172173string key = Environment.GetEnvironmentVariable("AWS_BEARER_TOKEN_BEDROCK")!;174ResponsesClient client = new(175 new ApiKeyCredential(key),176 new ResponsesClientOptions177 {178 Endpoint = new Uri("https://bedrock-mantle.us-east-2.api.aws/openai/v1"),179 }180);181182CreateResponseOptions options = new()183{184 Model = "openai.gpt-5.6-sol",185};186options.InputItems.Add(187 ResponseItem.CreateUserMessageItem("Write a haiku about cloud infrastructure.")188);189190ResponseResult response = await client.CreateResponseAsync(options);191192Console.WriteLine(response.GetOutputText());193```194195```ruby196require "openai"197198client = OpenAI::Client.new(199 provider: OpenAI::Providers.bedrock(200 region: "us-east-2",201 base_url: "https://bedrock-mantle.us-east-2.api.aws/openai/v1",202 api_key: ENV.fetch("AWS_BEARER_TOKEN_BEDROCK")203 )204)205206response = client.responses.create(207 model: "openai.gpt-5.6-sol",208 input: "Write a haiku about cloud infrastructure."209)210211puts(response.output_text)212```213214```bash215curl "https://bedrock-mantle.us-east-2.api.aws/openai/v1/responses" \216 -H "Content-Type: application/json" \217 -H "Authorization: Bearer $AWS_BEARER_TOKEN_BEDROCK" \218 -d '{219 "model": "openai.gpt-5.6-sol",220 "input": "Write a haiku about cloud infrastructure."221 }'222```223224225For long-running applications, prefer the standard AWS credential chain instead226of a static bearer token. The JavaScript, Python, Go, Java, and Ruby SDK227providers resolve fresh AWS credentials and sign each request attempt with228SigV4. The chain can include credentials configured with `aws login`, shared229profiles, workload roles, and instance or container credentials.230231Install optional dependencies for AWS credential-chain examples before using232this path:233234```shell235npm install @aws-sdk/credential-provider-node @smithy/hash-node @smithy/signature-v4236pip install 'openai[bedrock]'237go get github.com/openai/openai-go/v3/bedrock238bundle add aws-sdk-core239```240241The .NET SDK doesn't currently expose an equivalent Bedrock provider or AWS242SigV4 authentication policy. Use a Bedrock API key with .NET, or send a signed243HTTP request through an AWS-supported client when your application requires the244AWS credential chain.245246Send a request with AWS-managed Bedrock credentials247248```javascript249import OpenAI from "openai";250import { defaultProvider } from "@aws-sdk/credential-provider-node";251import { bedrock } from "openai/providers/bedrock/aws";252253const client = new OpenAI({254 provider: bedrock({255 region: "us-east-2",256 endpoint: "mantle",257 credentialProvider: defaultProvider(),258 }),259});260261const response = await client.responses.create({262 model: "openai.gpt-5.6-sol",263 input: "Write a haiku about cloud infrastructure.",264});265266console.log(response.output_text);267```268269```python270from openai import OpenAI271from openai.providers import bedrock272273client = OpenAI(274 provider=bedrock(275 region="us-east-2",276 api_key=None,277 )278)279280response = client.responses.create(281 model="openai.gpt-5.6-sol",282 input="Write a haiku about cloud infrastructure.",283)284285print(response.output_text)286```287288```go289package main290291import (292 "context"293 "fmt"294295 "github.com/aws/aws-sdk-go-v2/config"296 "github.com/openai/openai-go/v3"297 "github.com/openai/openai-go/v3/bedrock"298 "github.com/openai/openai-go/v3/responses"299)300301func main() {302 awsConfig, err := config.LoadDefaultConfig(context.Background())303 if err != nil {304 panic(err)305 }306307 client, err := bedrock.NewClient(context.Background(), bedrock.Config{308 AWSRegion: "us-east-2",309 AWSCredentialsProvider: awsConfig.Credentials,310 })311 if err != nil {312 panic(err)313 }314315 response, err := client.Responses.New(context.Background(), responses.ResponseNewParams{316 Model: "openai.gpt-5.6-sol",317 Input: responses.ResponseNewParamsInputUnion{318 OfString: openai.String("Write a haiku about cloud infrastructure."),319 },320 })321 if err != nil {322 panic(err)323 }324 fmt.Println(response.OutputText())325}326```327328```java329import com.openai.client.OpenAIClient;330import com.openai.client.okhttp.BedrockOpenAIOkHttpClient;331import com.openai.models.responses.ResponseCreateParams;332import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;333334public final class AmazonBedrockCreateResponseWithAwsCredentialsExample {335 private AmazonBedrockCreateResponseWithAwsCredentialsExample() {}336337 public static void main(String[] args) {338 OpenAIClient client =339 BedrockOpenAIOkHttpClient.builder()340 .awsRegion("us-east-2")341 .awsCredentialsProvider(DefaultCredentialsProvider.create())342 .build();343344 ResponseCreateParams params =345 ResponseCreateParams.builder()346 .model("openai.gpt-5.6-sol")347 .input("Write a haiku about cloud infrastructure.")348 .build();349350 client.responses().create(params).output().stream()351 .flatMap(item -> item.message().stream())352 .flatMap(message -> message.content().stream())353 .flatMap(content -> content.outputText().stream())354 .forEach(text -> System.out.println(text.text()));355 }356}357```358359```ruby360require "openai"361362client = OpenAI::Client.new(363 provider: OpenAI::Providers.bedrock(364 region: "us-east-2",365 base_url: "https://bedrock-mantle.us-east-2.api.aws/openai/v1",366 api_key: nil367 )368)369370response = client.responses.create(371 model: "openai.gpt-5.6-sol",372 input: "Write a haiku about cloud infrastructure."373)374375puts(response.output_text)376```377378379## Responses API feature availability380381Use this matrix to identify differences from the OpenAI API. Availability is382specific to the model and endpoint; a supported API does not imply support for383every tool or response mode.384385| Capability | OpenAI API | Amazon Bedrock |386| ------------------------- | ----------------------------- | ----------------------------- |387| Text generation | Available | Available |388| Image input | Available | Available |389| File input | Available | Available |390| Structured outputs | Available | Available |391| Function calling | Available | Available |392| Asynchronous tool calling | Available on supported models | Not available |393| Streaming responses | Available | Available |394| WebSocket connections | Available | Not available |395| Mid-turn steering | Available on supported models | Not available |396| Context window | Model-dependent | Model-dependent |397| Reasoning effort | Available | Available |398| Reasoning updates | Available on supported models | Not available |399| Pro mode | Available on supported models | Not available |400| Persisted reasoning | Available on supported models | Available on supported models |401| Prompt caching | Available | Available |402| Programmatic Tool Calling | Available on supported models | Not available |403| Multi-agent | Beta on supported models | Not available |404| Custom tools | Available | Available |405| Client-side `tool_search` | Available | Available |406| Hosted web search | Available | Mantle only |407| Hosted file search | Available | Not available |408| Computer use | Available | Available |409| Shell tool | Available | Not available |410| Image generation tool | Available | Not available |411| Remote MCP servers | Available | Not available |412413Asynchronous tool calling (`async: true`) and reasoning updates414(`configuration_update` input items) are not supported on Amazon Bedrock.415Mid-turn steering requires WebSockets and is not available through either416Bedrock endpoint.417418Client-side `tool_search` is distinct from hosted tools and remote MCP server419support. Hosted web search is available through Mantle; hosted file search and420remote MCP servers are unavailable.421422Computer use is available on Runtime and Mantle for supported models. Your423application executes computer actions and returns results to the model; this424capability does not require a Bedrock-hosted execution environment.425426On Amazon Bedrock, GPT-5.4 and GPT-5.5 support a 1-million-token context window;427GPT-5.6 Sol, Terra, Luna, and GPT-6 Astra support 1,050,000 tokens. Check the AWS [OpenAI model cards](https://docs.aws.amazon.com/bedrock/latest/userguide/model-cards-openai.html) for model-specific limits.428429### Endpoint differences430431These Responses API differences apply when choosing between Runtime and Mantle:432433| Capability | Bedrock Runtime | Mantle |434| -------------------------------------- | -------------------------------- | --------------------------------------------------------------------------- |435| GPT-6 Astra | Available | Available in `us-west-2` (Oregon) |436| Computer use | Available on supported models | Available on supported models |437| Streaming responses | Available | Available |438| Background mode (`background: true`) | Not available | Available, subject to [data retention settings](#data-access-and-retention) |439| Hosted web search | Not available | Available on supported models |440| Continuing with `previous_response_id` | Include `model` on every request | The model can be inherited from the previous response |441442Runtime requires `model` even when you supply `previous_response_id`. Background443mode is separate from streaming and does not describe asynchronous function444calling. Use the AWS [Responses API documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html) for the complete endpoint contract. For web search permissions and445configuration, see the AWS [web search guide](https://docs.aws.amazon.com/bedrock/latest/userguide/web-search.html).446447## Availability and operations448449AWS maintains the deployment options and availability for Amazon Bedrock. Use450these references to select and configure your deployment:451452| AWS-managed concern | AWS documentation |453| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |454| Model IDs and supported APIs | [OpenAI model cards](https://docs.aws.amazon.com/bedrock/latest/userguide/model-cards-openai.html) |455| Model and endpoint availability by AWS Region | [Model availability](https://docs.aws.amazon.com/bedrock/latest/userguide/models-region-compatibility.html) and [endpoint availability](https://docs.aws.amazon.com/bedrock/latest/userguide/endpoints-region-availability.html) |456| Geographic and global request routing | [Cross-Region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference.html) |457| Account quotas and increase requests | [Amazon Bedrock quotas](https://docs.aws.amazon.com/bedrock/latest/userguide/quotas.html) |458459An AWS Region is not an OpenAI data residency jurisdiction. If your workload has460location requirements, review the destination Regions of your inference profile461and the applicable AWS terms, not only the Region in your endpoint URL.462463## Data access and retention464465Amazon Bedrock uses separate controls for operator access and data retention:466467- **Zero operator access (ZOA)** means AWS operators have no technical mechanism468 to sign in to Mantle's underlying compute systems or access customer data469 there. See the AWS [ZOA design](https://aws.amazon.com/blogs/machine-learning/exploring-the-zero-operator-access-design-of-mantle/).470- **Zero data retention (ZDR)** means AWS does not write request or response data471 to durable storage when the effective retention mode is `none`.472473Setting `store: false` does not guarantee ZDR. For Responses API requests with an474effective retention mode of `none`, AWS rejects `store: true`, and background475mode is unavailable.476477For OpenAI models in Amazon Bedrock, AWS does not share request or response478content with OpenAI when the effective retention mode is `default` or `none`.479Use the AWS [data retention documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/data-retention.html) for available modes, eligibility, and account or project configuration. See [Amazon Bedrock abuse detection](https://docs.aws.amazon.com/bedrock/latest/userguide/abuse-detection.html) for model-specific retention requirements and exceptions.480481If AWS detects apparent CSAM in an image input, AWS may move the flagged input482 or output outside the ZOA environment and store and review it only to483 determine whether it is CSAM. AWS may also file a report with national484 authorities.485486## Authentication and operations487488Your AWS administrator controls account, model, and feature access. Use the AWS [API key documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html) for credential creation and lifecycle, and the [IAM documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/security-iam.html) for identities and permissions. The OpenAI SDK examples on this page show how to489supply those credentials; they do not configure AWS permissions.490491## Pricing492493Amazon Bedrock usage is billed through AWS. Bedrock pricing in commercial regions494matches OpenAI direct pricing for equivalent services. Note that using a495region-specific service in Bedrock will be priced at the same rate as Regional496processing in the OpenAI API. Amazon commercial terms apply to Bedrock usage.497498See [API pricing](https://developers.openai.com/api/docs/pricing) for direct OpenAI API pricing. For Bedrock499rates, supported service tiers, and billing options, use [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/) and the applicable model card.500501## Next steps502503For setup in ChatGPT Work and Codex, see504[Use ChatGPT Work and Codex with Amazon Bedrock](https://developers.openai.com/codex/amazon-bedrock).