Skip to content
agentgateway has joined the Agentic AI FoundationLearn more

For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.

Connect to AWS Bedrock AgentCore

Page as Markdown

Route requests to an Amazon Bedrock AgentCore agent runtime through agentgateway.

With agentgateway, you can route requests directly to an Amazon Bedrock AgentCore agent runtime with an aws.agentCore backend. You do not need a separate proxy, custom code, or the AWS SDK.

Important

Want to use agentgateway in a Kubernetes environment with the Gateway API? Check out the agentgateway on Kubernetes docs.

About AWS Bedrock AgentCore

Amazon Bedrock AgentCore is a runtime that hosts deployed agents, each with its own invocation endpoint. To reach an AgentCore runtime, you supply its Amazon Resource Name (ARN) to an aws.agentCore backend. Agentgateway derives every connection detail from that ARN, so you do not construct the endpoint or encode the ARN yourself.

For an ARN in the format arn:aws:bedrock-agentcore:<region>:<account-id>:runtime/<runtime-id>, agentgateway does the following:

  • Connects to bedrock-agentcore.<region>.amazonaws.com on port 443 over TLS, with the system trust store.
  • Replaces the request path with /runtimes/<url-encoded-ARN>/invocations.
  • Signs the request with AWS Signature Version 4 (SigV4) under the bedrock-agentcore signing name, unless a backend authentication policy overrides the signing.

The ARN must carry bedrock-agentcore as its service element. Agentgateway rejects any other ARN when it loads the configuration.

Note

AgentCore identifies a runtime entirely by its ARN, and the request path is replaced in full. A subpath that a client appends to the route, such as /agentcore/my-agent, is dropped, and the request still reaches the ARN in the backend. To route to more than one runtime, create a separate backend and route for each one. To target a different version or endpoint of the same runtime, set qualifier.

Authentication

AgentCore runtimes support two authentication modes, which you choose when you deploy the runtime in AWS. Both modes work with an aws.agentCore backend.

IAM (SigV4) is the default mode, and needs no policy. Agentgateway signs each request with the default AWS credential chain from its environment, such as environment variables, a shared credentials file, or an instance profile. To assume a role before signing, or to sign with an explicit access key, set a backendAuth.aws policy. For the full set of AWS options, see AWS backend authentication.

Before you begin

  1. Install the agentgateway binary.
  2. Deploy an Amazon Bedrock AgentCore agent runtime in your AWS account, and get its ARN. For steps to build and deploy a runtime, see the Amazon Bedrock AgentCore documentation.
  3. Get credentials for the runtime’s authentication mode.
    For IAM (SigV4), make AWS credentials that are allowed to invoke the runtime available to agentgateway. The credential chain reads environment variables, ~/.aws/config and ~/.aws/credentials, a web identity token, container credentials, and IMDSv2, and it stops at the first source that returns credentials.

Step 1: Configure the AgentCore backend

Create a configuration file with a route to the AgentCore runtime. The aws.agentCore settings name the runtime that you want to invoke, and the configuration depends on the runtime’s authentication mode.

  1. Create a configuration file with an aws.agentCore backend and no authentication policy. Agentgateway signs each request with SigV4 by using the credentials in its environment. Replace the agentRuntimeArn value with the ARN of your runtime.

    cat <<'EOF' > config.yaml
    # yaml-language-server: $schema=https://agentgateway.dev/schema/config
    gateways:
      default:
        port: 3000
    routes:
    - matches:
      - path:
          pathPrefix: /agentcore
      backends:
      - aws:
          agentCore:
            agentRuntimeArn: arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/my-agent-runtime
    EOF
  2. Start agentgateway with the configuration file.

    agentgateway -f config.yaml
SettingDescription
aws.agentCore.agentRuntimeArnThe ARN of the AgentCore agent runtime to invoke, in the format arn:aws:bedrock-agentcore:<region>:<account-id>:runtime/<runtime-id>. Agentgateway derives the endpoint, the signing region, and the invocation path from this value.
aws.agentCore.qualifierOptional. The runtime version or endpoint qualifier to invoke, which is sent as a qualifier query parameter. Omit this setting to use the runtime’s DEFAULT endpoint, as this example does.
policies.backendAuthOptional. Replaces the default SigV4 signing for the backend. Omit this setting to sign requests with the AWS credential chain. To authenticate to a runtime that uses a JWT authorizer, set backendAuth.key.value to the token, either as a file reference or as an inline string. The token goes in the Authorization header with a Bearer prefix, unless you set backendAuth.key.location.
policies.requestHeaderModifierOptional. Headers to set before the request is sent upstream, such as the X-Amzn-Bedrock-AgentCore-Runtime-User-Id header that AgentCore uses to associate requests with a user session. Omit this setting to send the request headers unchanged, as this example does.

To reuse one AgentCore backend across several routes, move the backend to a top-level backends entry and reference it by name. The reference is namespace-qualified, so a backend in the default namespace needs a leading slash.

backends:
- name: agentcore
  aws:
    agentCore:
      agentRuntimeArn: arn:aws:bedrock-agentcore:us-west-2:111122223333:runtime/my-agent-runtime
routes:
- matches:
  - path:
      pathPrefix: /agentcore
  backends:
  - backend: /agentcore

Step 2: Verify the connection

  1. Send a request to the AgentCore runtime through agentgateway. The request body depends on the agent that you deployed to the runtime. The following example sends a simple prompt.

    curl -X POST http://localhost:3000/agentcore \
      -H "Content-Type: application/json" \
      -d '{"prompt": "Hello from agentgateway!"}'

    Example output: The agent responds with its own payload format.

    {"result": {"role": "assistant", "content": [{"text": "Hello! How can I help you today?"}]}}
  2. In the terminal where agentgateway runs, verify that the request log names the AgentCore endpoint for the runtime’s region.

    info	request gateway=default/default listener=default route=default/route0 endpoint=bedrock-agentcore.us-west-2.amazonaws.com:443 src.addr=[::1]:49215 http.method=POST http.host=localhost http.path=/agentcore http.version=HTTP/1.1 http.status=200 protocol=http duration=437ms
  3. If the request fails, use the response and the request log to tell an authentication problem from a routing problem. A log line that carries an error= field and reason=UpstreamFailure means that agentgateway failed before it sent the request. A response that carries an x-amzn-requestid header came from AWS.

    ResponseCause
    403 with The security token included in the request is invalidThe SigV4 credentials that agentgateway resolved are not valid. Check the credential source that the chain reached first.
    403 from a JWT authorizerThe token is expired, or it does not match the runtime’s Inbound Auth settings. Check the discovery URL, the allowed client ID, and that you sent an access token.
    404 with No endpoint or agent found with qualifierThe ARN or the qualifier value does not name a deployed runtime endpoint. The message reports the qualifier that was used, which is DEFAULT when you omit the setting.
    500 with backend authentication failedagentgateway could not resolve credentials at all, so no request was signed. A failed assumeRole call reports this way.

Clean up

You can remove the resources that you created in this guide.
  1. Stop agentgateway in the terminal where it runs.

  2. Remove the configuration file and the token file.

    rm -f config.yaml config-jwt.yaml agentcore-token.jwt
Was this page helpful?
Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.