Skip to main content

Bedrock pass-through

The /bedrock route forwards Bedrock runtime paths, such as /model/{modelId}/converse, /model/{modelId}/invoke and /model/{modelId}/count-tokens, and Bedrock agent runtime paths such as knowledge base retrieval, to AWS. The gateway signs every request with SigV4 using its own AWS credentials, so callers need no AWS access at all. The virtual key is checked first, and the call is recorded in the spend logs.

A real-world scenario​

An analytics team uses the Bedrock Converse API from a service that runs outside AWS. Handing it IAM credentials means another secret to rotate and no per-team cost view. The service calls /bedrock/model/.../converse on the gateway with a virtual key instead. The gateway's task role signs the call, the IAM user is deleted, and the team's Bedrock spend shows up on the Logs page next to its other model spend.

Before you start​

The gateway needs AWS credentials and a region. Any AWS credential source works, including IAM roles, web identity and container credentials. It looks first for a model_list deployment of provider Bedrock with use_in_pass_through: true, then for the environment below.

VariablePurpose
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEYStatic credentials, when no role is available.
AWS_REGION_NAMEThe region of the Bedrock endpoint, such as us-east-1.

Steps​

  1. Give the gateway the credential. Open /ui/models-and-endpoints, on the Add Model tab pick Amazon Bedrock under Provider, pick a model, fill in the region and credentials, open Advanced Settings, turn on Use in pass through routes and click Add Model. Or run the gateway with an IAM role and set AWS_REGION_NAME.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Call Bedrock through the gateway.

    curl -X POST "http://localhost:4000/bedrock/model/us.anthropic.claude-sonnet-5-5/converse" \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"messages": [{"role": "user", "content": [{"text": "Summarise this ticket in one sentence."}]}]}'
  4. Open /ui/logs and click the newest row to see the request, the key and its cost.

Expected result​

AWS's own response, with its status code and headers. converse-stream and invoke-with-response-stream are streamed through as they arrive.

{
"output": {"message": {"role": "assistant", "content": [{"text": "The customer wants one of two duplicate charges refunded."}]}},
"stopReason": "end_turn",
"usage": {"inputTokens": 18, "outputTokens": 12, "totalTokens": 30}
}

The spend log row carries the key, team and user and the cost from usage. When the model id in the path names a deployment from model_list, the gateway routes through that deployment with its retries and fallbacks.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /bedrock/...The key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
403bedrock-agent-runtime pass-through is disabled on this proxy.The operator set general_settings.disable_bedrock_agent_runtime_passthrough. Use the unified endpoints or ask the operator to turn it back on.
400Could not extract model from endpoint ...The path carries no model id. Use /bedrock/model/{modelId}/{action}.
403 from AWSThe security token included in the request is invalidThe gateway signed with no usable AWS credentials. Set AWS_REGION_NAME and give the gateway a role or static credentials.
Any otherAWS's own error bodyAWS refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. Bedrock Converse and Bedrock Invoke are the gateway's own Bedrock endpoints with routing and fallbacks. The Bedrock provider page covers the unified integration, and MCP with AWS SigV4 covers MCP servers behind AWS IAM.