AWS Bedrock
Amazon Bedrock is an AWS service for accessing foundation models from Amazon and other providers through a managed API. AISIX gives applications one OpenAI-compatible interface for Bedrock-hosted Claude, Llama, Mistral, Amazon Nova, Cohere, and other models.
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, or sends a Bedrock API key as a bearer token; see Choose a Credential Mode.
Prerequisites
Before starting, prepare the following:
- One AISIX setup:
- For AISIX Enterprise or AISIX Cloud, an environment with an attached gateway and a write-scoped admin token. For AISIX Enterprise, follow the AISIX Enterprise getting-started guide. To request AISIX Cloud access, contact API7.
- For the open-source AISIX gateway, prepare either a local AISIX installation or the Docker setup from the AISIX OSS getting-started guide. Configure the gateway to load a declarative resources file.
- AWS credentials with
bedrock:InvokeModelpermission for the target model: an access key ID and secret access key, plus an STS session token for temporary credentials, or one of the other credential modes. - For cross-Region inference,
bedrock:InvokeModelpermission on the inference-profile ARN and on the foundation-model ARN in the source Region and every destination Region. See the requirements for geographic and global profiles. - Access to the target Bedrock model in the selected region, and its model ID or inference profile ID.
curlandjq.
Configure with AISIX Enterprise or AISIX Cloud
Export the control-plane connection details:
# AISIX_CP is the Admin API base URL; include /api and omit a trailing slash
# The local AISIX Enterprise quickstart uses http://localhost:8080/api
export AISIX_CP="YOUR_AISIX_CONTROL_PLANE_API_URL"
export AISIX_TOKEN="YOUR_ADMIN_TOKEN"
export ENV_ID="YOUR_ENVIRONMENT_ID"
Create the provider key with the Bedrock catalog provider and a structured config credential:
PROVIDER_KEY_ID=$(curl -sS -X POST "$AISIX_CP/provider_keys" \
-H "Authorization: Bearer $AISIX_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"display_name": "bedrock-prod",
"provider": "amazon-bedrock",
"config": {
"access_key_id": "YOUR_AWS_ACCESS_KEY_ID",
"secret_access_key": "YOUR_AWS_SECRET_ACCESS_KEY",
"region": "us-west-2"
},
"allowed_environments": ["'"$ENV_ID"'"]
}' | jq -r '.provider_key.id')
The credential travels in config, so the request omits api_key. Add session_token to config when you use temporary STS credentials. To authenticate another way, add auth_type to config; see Choose a Credential Mode.
api_base is optional. Without it, the control plane stores the runtime endpoint of the credential's region, https://bedrock-runtime.us-west-2.amazonaws.com in this example, or .amazonaws.com.cn in the China regions, and returns it like an explicit value. Set api_base for a private Bedrock endpoint. A region that is not a valid AWS Region name, or one in an isolated partition, needs an explicit api_base. When you later replace the credential with one for another region, an endpoint the control plane derived follows it to the new region.
In the dashboard, the provider key form's Authentication field selects the credential mode and shows the fields that mode takes.
Create an alias for Claude Sonnet 5. In us-west-2, in-Region inference is unavailable for this model, so the example uses its US geographic inference profile:
MODEL_ID=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/models" \
-H "Authorization: Bearer $AISIX_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"display_name": "claude-bedrock",
"model_name": "us.anthropic.claude-sonnet-5",
"provider_key_id": "'"${PROVIDER_KEY_ID}"'"
}' | jq -r '.model.id')
Create a caller API key that can access the model:
BEDROCK_CALLER_KEY=$(curl -sS -X POST "$AISIX_CP/environments/$ENV_ID/api_keys" \
-H "Authorization: Bearer $AISIX_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"display_name": "bedrock-caller",
"allowed_models": ["'"${MODEL_ID}"'"]
}' | jq -r '.plaintext')
Configure with AISIX OSS
Export the AWS credential and choose the caller API key that applications will send to AISIX:
# Replace with your values
export BEDROCK_CREDENTIALS='{"access_key_id":"YOUR_AWS_ACCESS_KEY_ID","secret_access_key":"YOUR_AWS_SECRET_ACCESS_KEY","region":"us-west-2"}'
export BEDROCK_CALLER_KEY="YOUR_CALLER_API_KEY"
export BEDROCK_CALLER_KEY_SHA256="$(printf '%s' "$BEDROCK_CALLER_KEY" | sha256sum | cut -d ' ' -f 1)"
For a new gateway, use this complete resources file. For an existing gateway, merge these entries into its current file, preserving its other resources.
_format_version: "2"
provider_keys:
- id: 5bb0b827-bcd8-41e6-a656-99177ac42ab6
display_name: bedrock-prod
provider: amazon-bedrock
adapter: bedrock
api_key: ${BEDROCK_CREDENTIALS}
models:
- id: 5c622aed-9736-4c81-bf3f-1fcdeabb807e
display_name: claude-bedrock
provider: amazon-bedrock
model_name: us.anthropic.claude-sonnet-5
provider_key_id: 5bb0b827-bcd8-41e6-a656-99177ac42ab6
api_keys:
- id: 64c25fc8-80c9-4ed2-b2b2-271c661861d5
display_name: bedrock-caller
key_hash: ${BEDROCK_CALLER_KEY_SHA256}
allowed_models: ["claude-bedrock"]
❶ provider labels the upstream.
❷ adapter selects Bedrock.
❸ api_key is a JSON string with access_key_id, secret_access_key, and region. The other credential modes use the same JSON string with different fields. 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.