Skip to main content

Cloud Platforms

Amazon Bedrock

Call Anthropic models on Amazon Bedrock through your Verdictan gateway. The gateway signs each request with AWS credentials from its own host, and your application calls the gateway with its application token.

This provider supports Anthropic models only. Your application can use the OpenAI Chat Completions or Responses format, or the Anthropic Messages format. The gateway sends every request to the Bedrock InvokeModel API in the Anthropic Messages format.

Before you start​

  • A working gateway from the quickstart.
  • An AWS region, and the Bedrock ID of one Anthropic model that you can use in that region.
  • AWS credentials on the gateway host that can invoke that model.
  • The gateway startup command, and a separate application token for test requests.

Configure the provider​

policy-config.yaml
pack:
  name: aws-bedrock-integration
  version: 1.0.0
  enabled: true
policies:
  chain:
    - prompt-injection
providers:
  targets:
    - id: bedrock-anthropic
      provider: aws-bedrock
      provider_type: aws-bedrock
      model: "anthropic.replace-with-model-id"
      bedrock_model_family: anthropic_messages
      aws_region: us-east-1
      base_url: https://bedrock-runtime.us-east-1.amazonaws.com

Each field has a fixed rule:

FieldRule
providerExactly aws-bedrock. The gateway rejects aliases such as bedrock.
provider_typeaws-bedrock. verdictan policy lint checks the other Bedrock fields only when this field is set.
modelMust contain anthropic..
bedrock_model_familyanthropic_messages, the only value.
aws_regionRequired. The gateway does not read AWS_REGION or AWS_DEFAULT_REGION.
base_urlRequired. Use https://bedrock-runtime.<aws_region>.amazonaws.com. An amazonaws.com host for another region is rejected.
aws_access_key_env, aws_secret_key_envOptional. The names of the environment variables that hold the AWS access key ID and the secret access key. Set both fields or neither.
aws_session_token_envOptional. The name of the environment variable that holds an AWS session token. It needs the other two fields.
aws_profileOptional. A named profile for the AWS default credential chain.

The target has no secret_key_ref. The gateway does not use secret_key_ref or api_key_prefix for this provider, and verdictan policy lint warns when secret_key_ref is set. The gateway signs each request with AWS Signature Version 4 for the host bedrock-runtime.<aws_region>.amazonaws.com. It calls /model/<model>/invoke, or /model/<model>/invoke-with-response-stream for streaming requests.

AWS credentials​

The gateway gets AWS credentials in this order:

  1. The variables that aws_access_key_env and aws_secret_key_env name, with the variable that aws_session_token_env names when that field is set.
  2. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from the gateway environment, with AWS_SESSION_TOKEN when it is set.
  3. If neither of the two variables is set, the AWS SDK default credential chain for aws_region. Set aws_profile on the target to use a named profile.

When the target sets the credential fields, the gateway uses only those variables. If one of them is not set or is empty, the request fails. If only one of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY is set, the request also fails. The gateway resolves credentials for each request, so verdictan config validate does not test them.

Use the credential fields when targets on one gateway need different AWS credentials. Use names with the VERDICTAN_ prefix:

policy-config.yaml
      aws_access_key_env: VERDICTAN_BEDROCK_ACCESS_KEY_ID
      aws_secret_key_env: VERDICTAN_BEDROCK_SECRET_ACCESS_KEY

Start and verify​

You can deploy this file with CLI 0.1.14 or later instead of the Console step below. The AWS credentials must remain available to the gateway. Check In sync, then test the configured Bedrock model.

With the quickstart in Docker, follow the container steps instead of steps 1 to 3.

  1. In the gateway terminal, set AWS credentials (add AWS_SESSION_TOKEN for temporary credentials), then check the file. policy lint checks the policy pack and the Bedrock fields, and config validate checks the provider target fields. On a host with an attached AWS role or a configured profile, skip the exports.

    export AWS_ACCESS_KEY_ID="replace-with-access-key-id"
    export AWS_SECRET_ACCESS_KEY="replace-with-secret-access-key"
    verdictan policy lint --file policy-config.yaml
    verdictan config validate --file policy-config.yaml
  2. Restart the test gateway with the AWS credentials in its environment.

  3. In Configurations in the Console, create or edit the test agent's configuration. Import the file and select Next. Under Deploy to agent, select the test agent. Select Deploy and confirm the gateway count. Wait about 30 seconds for the configuration pull. Use the signed request below to check the deployment.

  4. In a second terminal, send a request for the configured model:

    export VERDICTAN_CLIENT_TOKEN="<application-token>"
    curl --fail-with-body http://127.0.0.1:41002/v1/chat/completions \
      -H "Authorization: Bearer ${VERDICTAN_CLIENT_TOKEN}" \
      -H "Content-Type: application/json" \
      -d '{"model":"anthropic.replace-with-model-id","max_tokens":128,"messages":[{"role":"user","content":"Reply with Hello."}]}'

choices[0].message.content contains the reply. A reply proves the whole path: application token, AWS credentials, signature, region, and model access. The request appears in History when capture is on, or in the delivered events.

Supported requests​

RequestSupport
Chat CompletionsYes. Translated to the Anthropic Messages format. Streaming and tools work.
ResponsesYes. Translated to the Anthropic Messages format. Send input as a string, or as messages with text content.
MessagesYes. Streams come back in the Anthropic event format.
Image and PDF inputYes, as Chat Completions image_url parts or PDF document blocks
response_format with json_object or json_schema, parallel_tool_calls: true, strict tools, extended thinking, anthropic-beta headersNo. The gateway rejects the request with HTTP 422 before it calls Bedrock.
Embeddings, non-Anthropic modelsNo

All three supported request families go through your policy chain.

The gateway translates requests in the same way as for the Anthropic provider, with the same limits. It also sets anthropic_version to bedrock-2023-05-31 in the request body. For streaming requests, it decodes the Bedrock event stream into server-sent events.

Failure behavior​

ProblemResult or cause
Lint reports provider 'bedrock' must use exact provider id 'aws-bedrock'provider is an alias. Set it to aws-bedrock.
Lint or config validate names aws_region, bedrock_model_family, or an Anthropic model idA required field is missing, or model does not contain anthropic..
Lint or config validate reports that the base_url host must match aws_regionbase_url names another region.
config validate reports base_url is requiredAdd base_url.
Lint or config validate reports set aws_access_key_env and aws_secret_key_env togetherThe target sets only one of the two fields, or sets aws_session_token_env without them.
Lint reports secret_key_ref is not usedRemove secret_key_ref from the target.
502 with provider_auth_failed and which is not set or emptyA variable that a credential field names is not set on the gateway host.
502 with provider_auth_failed and found only one of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEYSet both variables, or neither to use the default credential chain.
502 with provider_auth_failed and AWS credential resolution failedThe default credential chain found no credentials. Check the profile, role, or environment of the gateway host.
401 from the gatewayThe application token is not active.
422 with runtime.structured_output.unsupported_feature, runtime.tooling.unsupported_feature, or runtime.beta_header.unsupportedThe request uses a feature from the last rows of Supported requests.
Bedrock returns an error statusThe client gets the same status with code upstream_provider_error and the message Upstream provider returned HTTP <status>. The Bedrock error body is not returned. Check IAM permissions, model access, and the region. If another target is eligible, some errors move the request to that target first.
A stream stops with an errorBedrock sent an exception event, such as a throttling or validation error, during the stream.

Limits​

  • Model IDs, regions, prices, quotas, and permissions are in the Amazon Bedrock documentation.
  • One target serves one model in one region. Add a target for each model or region.
  • If the Bedrock call fails with a rate limit, a server error, an authentication error, or a transport error, the gateway tries the next eligible target. Provider attempts and fallback has the rules.
  • A listener on a non-loopback address needs TLS and network controls.

Next steps​