Contenox

AWS Bedrock coding agent: Claude Code, Codex, OpenCode

Updated

AWS Bedrock

An AWS Bedrock coding agent sends its model requests to Bedrock in your own AWS account, so usage lands on your AWS bill and stays under your company’s IAM rules. Claude Code runs Claude models on Bedrock, Codex CLI runs OpenAI models on Bedrock, and OpenCode has Bedrock built in. Most setup trouble is access: the model is listed, but the first call fails with AccessDeniedException.

Use Bedrock with your agent#

Agent Supported? How Note
Claude Code Yes, Claude models Run claude, choose 3rd-party platform → Amazon Bedrock; or CLAUDE_CODE_USE_BEDROCK=1 Claude Code runs Claude models only
Codex Yes, supported OpenAI models Select Use Amazon Bedrock during desktop or CLI sign-in. You need an AWS account with access to the model in the selected region.
OpenCode Yes, built in AWS_PROFILE and AWS_REGION, or an amazon-bedrock block in opencode.json Any model your account can call
Contenox Harness Yes Backends → Providers → AWS Bedrock Lists the text models your region offers

Before you start#

Every agent uses the same AWS side.

Credentials on your machine, from aws configure, aws login, aws sso login or environment variables. Short-lived credentials from SSO or a role are safer than long-lived access keys. Check them:

aws sso login --profile my-dev-profile
aws sts get-caller-identity --profile my-dev-profile

If the second command prints your account and role, the agent can use the same credentials. It checks who you are, not whether you may call a model.

An IAM identity that may call Bedrock. A minimal policy for an agent:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "bedrock:ListFoundationModels",
        "bedrock:ListInferenceProfiles",
        "bedrock:GetInferenceProfile"
      ],
      "Resource": "*"
    },
    {
      "Effect": "Allow",
      "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
      "Resource": [
        "arn:aws:bedrock:*::foundation-model/*",
        "arn:aws:bedrock:*:*:inference-profile/*",
        "arn:aws:bedrock:*:*:application-inference-profile/*"
      ]
    }
  ]
}

Claude Code uses bedrock:GetInferenceProfile to resolve application inference profiles; without it, requests still work but take an extra round trip.

Model access. In commercial regions, Bedrock enables most models the first time someone in the account calls them. Two things still have to be in place:

  • AWS Marketplace permissions for that first call to a third-party model: aws-marketplace:Subscribe, aws-marketplace:Unsubscribe and aws-marketplace:ViewSubscriptions. After someone has enabled the model once, other users don’t need them.
  • For Anthropic models, a one-time use case form. Open a Claude model from Model catalog in the Bedrock console and fill it in. With AWS Organizations, the management account can submit it once for all child accounts.

AWS’s model access guide has the details.

Claude Code#

The quickest way is the built-in wizard. Run claude, and at the login prompt choose 3rd-party platform, then Amazon Bedrock. It finds your AWS profiles, asks for a region, checks which Claude models your account can call and lets you pin them. It saves everything to ~/.claude/settings.json. Already signed in? Type /setup-bedrock in full; the command is hidden from the menu until Bedrock is on.

To set it up by hand, for example in scripts, in PowerShell on Windows:

$env:CLAUDE_CODE_USE_BEDROCK = "1"
$env:AWS_PROFILE = "my-dev-profile"
$env:AWS_REGION = "us-east-1"
claude

On macOS or Linux:

export CLAUDE_CODE_USE_BEDROCK=1
export AWS_PROFILE=my-dev-profile
export AWS_REGION=us-east-1
claude

AWS_REGION is optional if your profile already sets a region. Run /status to see which region Claude Code resolved.

Pin the models when you roll this out to a team. Otherwise the opus and sonnet aliases follow Claude Code’s built-in defaults, which may not be enabled in your account:

export ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-5-5'
export ANTHROPIC_DEFAULT_SONNET_MODEL='us.anthropic.claude-sonnet-4-6'

In PowerShell, use $env:ANTHROPIC_DEFAULT_OPUS_MODEL = "us.anthropic.claude-opus-5-5" and so on. The us. prefix is a cross-region inference profile; use eu., apac. or global. to match your region.

To refresh an expired SSO login automatically, add "awsAuthRefresh": "aws sso login --profile my-dev-profile" to ~/.claude/settings.json. If browser tabs keep opening behind a corporate VPN or proxy, remove it and run aws sso login yourself before starting Claude Code.

Built-in web search isn’t available on Bedrock, and Claude Code runs only Claude models. For other Bedrock models, use OpenCode or Contenox Harness.

Codex in the desktop app or CLI#

In the signed-out ChatGPT desktop app, choose Sign in another way → Use Amazon Bedrock. Choose an AWS profile, access keys or a Bedrock API key. For an existing profile, enter its name and region. In the terminal, start codex, choose Use Amazon Bedrock, and select the credentials detected on your machine or enter your own. Start a local task and request a short reply to confirm the selected model is accessible. OpenAI’s illustrated Bedrock setup

For a manual configuration, enter the model available to your AWS account in ~/.codex/config.toml. For example:

model_provider = "amazon-bedrock-runtime"
model = "global.openai.gpt-6-astra"
web_search = "disabled"

Then set your profile and start Codex. In PowerShell:

$env:AWS_PROFILE = "my-dev-profile"
codex

On macOS or Linux:

export AWS_PROFILE=my-dev-profile
codex

Codex checks for a Bedrock API key in AWS_BEARER_TOKEN_BEDROCK first, then the normal AWS credential chain. With an API key, AWS_REGION is required. Run /status in Codex to confirm the provider.

OpenAI recommends the Runtime endpoint for new setups. The other provider, amazon-bedrock, uses the Mantle endpoint and is the one to use if you need hosted web search. ChatGPT sign-in and OPENAI_API_KEY aren’t used on Bedrock.

OpenCode#

OpenCode reads the standard AWS variables. In PowerShell:

$env:AWS_PROFILE = "my-dev-profile"
$env:AWS_REGION = "us-east-1"
opencode

On macOS or Linux:

export AWS_PROFILE=my-dev-profile
export AWS_REGION=us-east-1
opencode

To select the same profile in project configuration, create opencode.jsonc:

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "amazon-bedrock": {
      "settings": {
        "region": "us-east-1",
        "profile": "my-dev-profile"
      }
    }
  }
}

Open /models to choose a Bedrock model. A region alone does not activate Bedrock. For a Bedrock API key, use AWS_BEARER_TOKEN_BEDROCK. OpenCode Bedrock setup

Contenox Harness#

  1. Sign in with the AWS CLI, then start Contenox Harness.
  2. Open Backends → Providers and, under Cloud, choose AWS Bedrock.
  3. In AWS region or Bedrock runtime URL, enter a region such as us-east-1.
  4. Select Connect and wait for Connected.

Contenox Harness uses the standard AWS credential chain. If your SSO profile isn’t the default one, run setx AWS_PROFILE my-dev-profile on Windows and restart Contenox Harness. If you can’t use the chain, open Advanced and fill in AWS static credentials JSON with access_key_id, secret_access_key and an optional session_token.

The list shows the text models your region offers, not what your account has enabled, so a listed model can still fail until access is set up. Download Contenox Harness.

Which Bedrock models work for a coding agent?#

  • Look for tool use. The agent reads files and runs commands through tool calls. Claude models are the common choice for agent work on Bedrock.
  • Inference profile IDs start with us., eu., apac., global. or similar. Some newer models can only be called through a profile, not by their plain model ID. “On-demand throughput isn’t supported” means you need the profile ID.
  • Compare on a real task. Bedrock hosts several vendors; OpenCode and Contenox Harness let you switch between them per session.

Common errors#

Error Likely cause Fix
AccessDeniedException on first use Missing Marketplace permissions, or the Anthropic form isn’t done Add the permissions or submit the form, then wait a few minutes
AccessDeniedException with an inference profile Your IAM policy allows only one region, but the profile routes to several Allow bedrock:InvokeModel* in every destination region of the profile, or use * for the region
On-demand throughput isn’t supported You used a plain model ID for a profile-only model Use the inference profile ID
Expired or missing credentials The SSO session ran out Run aws sso login again, then restart the agent if calls still fail
ThrottlingException You hit an account quota Wait, or request a quota increase in AWS

Service control policies can also block regions that a cross-region profile uses. If you are in an AWS Organization and the policy looks right, ask your administrator.

What does it cost?#

Bedrock bills per token, at rates set per model and region, on your AWS bill. Quotas limit requests and tokens per minute. See Bedrock pricing, quotas and models by region.

Startup credits#

For an eligible startup, AWS Activate gives AWS credits that cover model usage billed to the account, which can make this the cheapest way to run strong models for a while. Check which models count before relying on it; partner models can be billed differently from the cloud’s own. Treat the credits as a temporary discount: record the undiscounted monthly cost and the credit expiry date before building on the service, so the decision to stay, move or stop is made before the subsidy ends.