Skip to main content

AWS Bedrock Upstream

In this guide, you will route AISIX AI Gateway to AWS Bedrock. Callers can reach Claude, Llama, Mistral, Amazon Nova, Cohere, and other Bedrock-hosted models through the gateway's OpenAI-compatible API.

This configuration is for Bedrock-hosted models that should use AISIX authentication, model allowlists, rate limits, and usage accounting. AISIX signs outbound Bedrock calls with AWS SigV4.

Prerequisites

Before starting, prepare the following:

  • A gateway with the admin API on :3001 and the proxy API on :3000.
  • The admin key from the gateway config.yaml.
  • AWS credentials with bedrock:InvokeModel permission for the target model.
  • Access to the target Bedrock model in the selected region.
  • The AWS access key ID, secret access key, region, optional STS session token, Bedrock model ID or inference profile ID, and caller-facing alias.

Configure the Bedrock Upstream

Create a Bedrock provider key, model alias, and caller API key. The provider key stores the AWS credential, while the model selects the Bedrock model ID or inference profile.

Create a Bedrock Provider Key

Create the Bedrock provider key with the AWS credential settings:

export AISIX_ADMIN_KEY="admin-local-only-change-me"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/provider_keys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"display_name": "bedrock-prod",
"provider": "amazon-bedrock",
"adapter": "bedrock",
"secret": "{\"access_key_id\":\"YOUR_AWS_ACCESS_KEY_ID\",\"secret_access_key\":\"YOUR_AWS_SECRET_ACCESS_KEY\",\"region\":\"us-west-2\"}"
}'

Provider key secrets follow the credential-handling behavior described in Provider Keys.

provider labels the upstream.

adapter selects Bedrock.

secret is a JSON string with access_key_id, secret_access_key, and region. Bedrock's endpoint is region-keyed, for example bedrock-runtime.us-west-2.amazonaws.com, so the region is required. Leave api_base unset for standard AWS, or set it to a private Bedrock endpoint if you use one.

Include session_token when you use temporary STS credentials. Omit it for long-lived static keys.

Save the returned provider key ID for the model resource.

Create a Model

Map a caller-facing alias to the Bedrock model ID:

export PROVIDER_KEY_ID="YOUR_PROVIDER_KEY_ID"

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/models" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"display_name": "claude-bedrock",
"provider": "amazon-bedrock",
"model_name": "anthropic.claude-3-5-sonnet-20241022-v2:0",
"provider_key_id": "'"${PROVIDER_KEY_ID}"'"
}'

provider uses the same label as the provider key.

model_name is the Bedrock model ID.

provider_key_id attaches the model to the Bedrock credential.

For a non-Claude model, set model_name to the publisher's Bedrock ID, for example meta.llama3-3-70b-instruct-v1:0 or amazon.nova-pro-v1:0.

If you use a Bedrock inference profile, put the full inference profile ID in model_name.

Create a Caller API Key

Choose the plaintext caller API key that the application will send to AISIX, then hash it for the admin resource:

export AISIX_API_KEY="sk-bedrock-caller"

CALLER_KEY_HASH=$(printf '%s' "${AISIX_API_KEY}" | shasum -a 256 | awk '{print $1}')

Create the API key resource with access to the Bedrock-backed model alias:

curl -sS -X POST "http://127.0.0.1:3001/admin/v1/apikeys" \
-H "Authorization: Bearer ${AISIX_ADMIN_KEY}" \
-H "Content-Type: application/json" \
-d '{
"key_hash": "'"${CALLER_KEY_HASH}"'",
"allowed_models": ["claude-bedrock"]
}'

allowed_models must match the model alias you created.

Verify the Upstream

Send a chat-completions request through the AISIX proxy:

curl -sS -X POST "http://127.0.0.1:3000/v1/chat/completions" \
-H "Authorization: Bearer ${AISIX_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-bedrock",
"messages": [
{"role": "user", "content": "Say hello from Bedrock."}
]
}'

The gateway returns an OpenAI-compatible response with the caller-facing alias:

{
"id": "msg_01example",
"object": "chat.completion",
"model": "claude-bedrock",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello from Bedrock!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 5,
"total_tokens": 14
}
}

Check Bedrock invocation metrics, CloudTrail, or provider-side logs for the test request. If AISIX returns an upstream authentication or authorization error, check the AWS credential, region, IAM permissions, and Bedrock model access.

Before Production

If applications use streaming, add bedrock:InvokeModelWithResponseStream to the AWS permissions and confirm streaming behavior with the target model.

For non-Claude Bedrock models, send at least one user or assistant message. Bedrock Converse does not accept system-only requests, so AISIX rejects them before calling the provider.

Upstream error detail from AWS is redacted in the caller-visible error to avoid leaking AWS identifiers such as ARNs, region, and account ID.

Next Steps

You have now configured AWS Bedrock as an upstream provider family. Use the same pattern for other Bedrock models by changing the region, credential, model ID, and caller-facing alias.

API7.ai Logo

The digital world is connected by APIs,
API7.ai exists to make APIs more efficient, reliable, and secure.

Sign up for API7 newsletter

Product

API7 Gateway

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2026. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the Apache Software Foundation