Amazon Bedrock OpenAI-Compatible API: Base URL, Auth, Models, and Code (2026)
Yes. Amazon Bedrock has an OpenAI-compatible API. Point the OpenAI SDK at https://bedrock-runtime.{region}.amazonaws.com/openai/v1, authenticate with a Bedrock API key (or AWS SigV4), and pass a Bedrock model ID such as openai.gpt-oss-120b-1:0. Bedrock serves both the Chat Completions and Responses APIs this way. AWS recommends the bedrock-runtime endpoint for new applications and keeps bedrock-mantle as a compatibility option. One catch: bedrock-runtime doesn't implement GET /models. All details are from the official Bedrock Chat Completions docs, checked on October 20, 2026.
This guide covers both endpoints, the two API-key types, model IDs, curl, Python, and Node code, guardrails, pricing, the errors you'll hit, and when Bedrock is a better fit than a multi-provider gateway.
Quick reference
| Item | Value (as of Oct 20, 2026) |
|---|---|
| Recommended base URL | https://bedrock-runtime.{region}.amazonaws.com/openai/v1 |
| Compatibility base URL | https://bedrock-mantle.{region}.api.aws/v1 (some models use /openai/v1) |
| OpenAI APIs supported | Chat Completions, Responses (per model), plus the Anthropic Messages API |
| Auth | Bedrock API key as Authorization: Bearer …, or AWS SigV4 |
| Example model IDs | openai.gpt-oss-120b-1:0, openai.gpt-oss-20b-1:0, global.openai.gpt-5.6-sol |
List models via /models |
Only on bedrock-mantle. Use ListFoundationModels on bedrock-runtime |
| Region scope | Keys and endpoints are regional |
Sources: Chat Completions API, Inference endpoints, Quickstart.
bedrock-runtime vs bedrock-mantle: which endpoint to use
AWS says both endpoints "use the same underlying Mantle inference engine". The name identifies an endpoint surface, not a different engine. They differ in features:
bedrock-runtime (recommended) |
bedrock-mantle (compatibility) |
|
|---|---|---|
| Base URL | bedrock-runtime.{region}.amazonaws.com/openai/v1 |
bedrock-mantle.{region}.api.aws/v1 |
| APIs | InvokeModel, Converse, Chat Completions, Responses, Messages | Chat Completions, Responses, Messages |
GET /models |
Not implemented (404 UnknownOperationException) |
Supported |
| Guardrails, intelligent prompt routing, cross-Region inference | Yes | Check the model card |
| Server-side tools (for example web search), background inference, Projects, Workspaces | No | Yes |
| Quotas | Per-model quotas for this endpoint | Separate per-model quotas |
Rule of thumb from AWS: start on bedrock-runtime. Switch to bedrock-mantle only if a model or feature you need is available only there. On bedrock-mantle, the path prefix varies by model. A request with the wrong prefix fails with "model … isn't supported on this route", so check the model card's Programmatic Access table.
Authentication: Bedrock API keys vs SigV4
Bedrock API keys let the OpenAI SDK authenticate with a bearer token instead of signing requests with AWS credentials (API keys docs, Oct 20, 2026):
| Key type | Lifetime | Backed by | AWS recommendation |
|---|---|---|---|
| Short-term | Up to 12 hours (or the session length) | Permissions of the IAM principal that generated it | Production |
| Long-term | Until a configured expiry | A dedicated IAM user with attached policies | Exploration only |
Practical notes:
- Generate short-term keys in code with
pip install aws-bedrock-token-generator(Python) ornpm install @aws/bedrock-token-generator(Node), and call the provider before each request. It returns a cached token while that token is still valid. - Long-term keys only work in the Region where they were created. A cross-Region call fails with
Credential should be scoped to a valid region. - Restrict key usage with the IAM actions
bedrock:CallWithBearerTokenandbedrock-mantle:CallWithBearerToken. - API calls are logged in CloudTrail. The keys themselves are not logged.
- With boto3, the
AWS_BEARER_TOKEN_BEDROCKvariable requires boto3 1.39.0 or later (Quickstart).
Code: call Bedrock with the OpenAI SDK
curl (API key)
export OPENAI_API_KEY="<bedrock-api-key>"
curl -X POST "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{"model": "openai.gpt-oss-120b-1:0",
"messages": [{"role": "user", "content": "Hello from Bedrock"}]}'
curl (SigV4, no API key)
curl -X POST "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1/chat/completions" \
-H "Content-Type: application/json" \
--aws-sigv4 "aws:amz:us-east-1:bedrock" \
--user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
-d '{"model": "openai.gpt-oss-120b-1:0", "messages": [{"role": "user", "content": "Hello"}]}'
Python with auto-refreshing short-term keys
from aws_bedrock_token_generator import provide_token # pip install aws-bedrock-token-generator openai
from openai import OpenAI
REGION = "us-east-1"
def bedrock_client() -> OpenAI:
# provide_token() returns a cached token or mints a fresh short-term key (<= 12h)
return OpenAI(base_url=f"https://bedrock-runtime.{REGION}.amazonaws.com/openai/v1",
api_key=provide_token())
r = bedrock_client().chat.completions.create(
model="openai.gpt-oss-120b-1:0",
messages=[{"role": "user", "content": "Explain Bedrock API keys in one sentence."}],
)
print(r.choices[0].message.content, r.usage)
Node.js
import OpenAI from "openai";
import { getTokenProvider } from "@aws/bedrock-token-generator";
const provideToken = getTokenProvider();
const client = new OpenAI({
baseURL: "https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1",
apiKey: await provideToken(),
});
const r = await client.chat.completions.create({
model: "openai.gpt-oss-20b-1:0",
messages: [{ role: "user", content: "Name two Bedrock endpoints." }],
});
console.log(r.choices[0].message.content);
Listing models
client.models.list() returns 404 on bedrock-runtime. Either call aws bedrock list-foundation-models --region us-east-1, or point the SDK at bedrock-mantle to list models:
curl -s "https://bedrock-mantle.us-east-1.api.aws/v1/models" -H "Authorization: Bearer $OPENAI_API_KEY"
Add a Bedrock Guardrail to an OpenAI-style request
Guardrails are passed as extra headers. An optional body field enables input tagging:
r = bedrock_client().chat.completions.create(
model="openai.gpt-oss-20b-1:0",
messages=[{"role": "user", "content": "What is the weather like today?"}],
extra_headers={
"X-Amzn-Bedrock-GuardrailIdentifier": "GR12345",
"X-Amzn-Bedrock-GuardrailVersion": "DRAFT",
"X-Amzn-Bedrock-Trace": "ENABLED",
},
extra_body={"amazon-bedrock-guardrailConfig": {"tagSuffix": "xyz"}},
)
The header names come from the official guardrail example.
Which models work with the OpenAI-compatible API?
API support varies by model and by endpoint, so check each model card (API compatibility table). Examples from AWS docs as of October 20, 2026:
| Model | Chat Completions on runtime | Responses on runtime | Notes |
|---|---|---|---|
openai.gpt-oss-120b-1:0 / -20b-1:0 |
Yes | No (Responses only on mantle) | Open-weight GPT OSS |
global.openai.gpt-5.6-sol |
Yes | Yes | Shown in the AWS Quickstart, global inference profile |
| GPT-6 family, GPT-5.x | Per model card | Per model card | Listed in the OpenAI section of the compatibility table |
| Anthropic Claude | Use the Messages API (/anthropic) |
n/a | ANTHROPIC_BASE_URL=https://bedrock-runtime.{region}.amazonaws.com/anthropic |
Bedrock pricing for OpenAI-compatible calls
You pay the normal Bedrock per-token rate for the model. The OpenAI-compatible interface doesn't carry a surcharge. Examples from the Bedrock pricing page, October 20, 2026, per 1M tokens:
| Model | Region | Input | Output |
|---|---|---|---|
| gpt-oss-20b | Asia Pacific (Sydney) | $0.0721 | $0.3090 |
| gpt-oss-120b | Asia Pacific (Sydney) | $0.1545 | $0.6180 |
| GPT OSS Safeguard 20B | US East/West | $0.07 | $0.20 |
| GPT OSS Safeguard 120B | US East/West | $0.15 | $0.60 |
Rates vary by Region, and Bedrock also sells Priority, Flex, and Batch tiers. Use the Region selector on the pricing page for the exact rate you'll pay.
Common errors and fixes
| Error | Cause | Fix |
|---|---|---|
404 UnknownOperationException on /models |
bedrock-runtime doesn't implement the Models API |
Use ListFoundationModels, or call /models on bedrock-mantle |
model … isn't supported on this route |
Wrong path prefix on bedrock-mantle |
Check the model card for /v1 vs /openai/v1 |
Credential should be scoped to a valid region |
Long-term key used outside its Region | Generate a key in the target Region |
Unable to locate credentials |
boto3 older than 1.39.0 ignores AWS_BEARER_TOKEN_BEDROCK |
pip install --upgrade boto3 |
| Responses API not supported for GPT OSS | GPT OSS supports Responses only on bedrock-mantle |
Use Chat Completions or switch endpoints |
AccessDenied |
Missing model access or CallWithBearerToken denied |
Enable model access and review IAM policies |
Bedrock vs direct OpenAI vs a multi-provider gateway
| Need | Bedrock OpenAI-compatible | Direct provider API | Multi-provider gateway (e.g. Flatkey) |
|---|---|---|---|
| Stay inside an AWS account, IAM, and CloudTrail | Best | No | No |
| Use AWS credits or Enterprise Discount Program (EDP) commitments | Yes | No | No |
| Guardrails and VPC-adjacent controls | Yes | Provider-specific | Gateway-specific |
| Newest model the day it launches | Varies by model | Usually first | Varies |
| One key across OpenAI, Anthropic, Google, Alibaba, DeepSeek, Moonshot, Zhipu | Only Bedrock-hosted models | No | Yes |
| Regional key management | Required | No | No |
If you're all-in on AWS, Bedrock's OpenAI-compatible API is the cleanest option. If you also need models Bedrock doesn't host, keep the same OpenAI SDK code and swap the base URL. With Flatkey, one key at https://router.flatkey.ai/v1 reaches GPT, Claude, Gemini, Qwen, DeepSeek, Kimi, and GLM:
import os
from openai import OpenAI
ROUTES = {
"bedrock": OpenAI(base_url="https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1",
api_key=os.environ["AWS_BEARER_TOKEN_BEDROCK"]),
"flatkey": OpenAI(base_url="https://router.flatkey.ai/v1",
api_key=os.environ["FLATKEY_API_KEY"]),
}
def ask(route, model, prompt):
r = ROUTES[route].chat.completions.create(model=model, messages=[{"role": "user", "content": prompt}])
return r.choices[0].message.content
print(ask("bedrock", "openai.gpt-oss-120b-1:0", "hi"))
print(ask("flatkey", "qwen3.8-max", "hi")) # same SDK, different provider
print(ask("flatkey", "claude-sonnet-5-5", "hi"))
As of October 20, 2026, the gpt-6-sol page on Flatkey lists $1.20 input and $6.00 output per 1M tokens, a promotional price against a $2 / $10 list. Compare it with your Bedrock rate for the same model. More context: OpenAI-compatible API base URLs, direct provider accounts vs an AI API gateway, and enterprise AI API gateway checklist.
Migration checklist: OpenAI app to Bedrock
- Pick the Region and confirm model access in the Bedrock console.
- Replace
OPENAI_BASE_URLwithhttps://bedrock-runtime.{region}.amazonaws.com/openai/v1. - Replace the key with a short-term Bedrock API key provider. Don't ship long-term keys to production.
- Map model names to Bedrock IDs, such as
gpt-oss-120b→openai.gpt-oss-120b-1:0. - Remove
client.models.list()calls, or move them tobedrock-mantle. - Test streaming, tool calls, and structured output per model card.
- Add guardrail headers where policy requires them.
- Check quotas for the endpoint you chose (rate-limit handling).
- Track spend per model and team (cost attribution).
FAQ
Does Amazon Bedrock support the OpenAI API?
Yes. Bedrock implements the OpenAI Chat Completions and Responses APIs at https://bedrock-runtime.{region}.amazonaws.com/openai/v1, so existing OpenAI SDK code works by changing the base URL, the API key, and the model ID.
What is the Bedrock OpenAI-compatible base URL?
https://bedrock-runtime.{region}.amazonaws.com/openai/v1 is the recommended URL, for example https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1. The compatibility endpoint is https://bedrock-mantle.{region}.api.aws/v1.
How do I authenticate the OpenAI SDK with Bedrock?
Use an Amazon Bedrock API key as the api_key, sent as Authorization: Bearer. AWS recommends short-term keys (up to 12 hours) for production. SigV4 signing also works on bedrock-runtime.
Why does models.list() fail on Bedrock?
The bedrock-runtime endpoint doesn't implement the OpenAI GET /models operation and returns 404 UnknownOperationException. Use ListFoundationModels, or call /models on bedrock-mantle.
Can I use GPT OSS with the Responses API on Bedrock?
Not on bedrock-runtime. GPT OSS supports Chat Completions there, and the Responses API for GPT OSS is available only on bedrock-mantle.
Is there an extra charge for the OpenAI-compatible endpoint?
AWS doesn't list a separate fee for the interface. You pay the model's standard Bedrock token pricing for your Region and tier.
Bottom line
To use the OpenAI SDK on AWS, set the base URL to bedrock-runtime.{region}.amazonaws.com/openai/v1, use short-term Bedrock API keys, map your model IDs, and drop models.list(). If your stack also needs models outside Bedrock, the same SDK pattern works with one key through the Flatkey router.
Last updated: October 20, 2026 · Flatkey Team. Details are quoted from the official AWS documentation linked inline.


