docs/bedrock.md
CodexBar reads AWS Cost Explorer for Bedrock spend and can compare the current month against an optional budget. When permitted, it also reads CloudWatch for rolling 14-day Claude token and request totals in the configured region.
Monitoring Bedrock spend can add charges to your AWS bill. AWS currently charges $0.01 per Cost Explorer API request against the primary billing view, separately from Bedrock inference charges. See the AWS Cost Explorer pricing page for current rates. For example, 5,000 billed requests cost $50 at that rate. A CodexBar refresh is not a fixed-price unit: monthly spend, daily cost history, and paginated responses can make separate requests. Optional CloudWatch activity uses another API and is subject to CloudWatch pricing.
To reduce automatic requests, open Settings → General → Refreshing and choose a longer refresh interval or Manual. This setting applies to all providers. Manual stops the recurring timer; startup, explicit refreshes, and Refresh when the menu opens can still fetch data. Turn off that option as well to reduce menu-triggered requests. Disable AWS Bedrock in Providers to stop its app refreshes; separate CLI invocations can still make billed requests.
The optional monthly budget only changes the displayed progress. It does not cap AWS charges or stop polling.
CodexBar supports two authentication modes, selected in Preferences → Providers → AWS Bedrock → Authentication.
Provide static AWS credentials through Settings or the environment inherited by CodexBar/the CLI:
export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."
export AWS_REGION="us-east-1"
Optional:
export AWS_SESSION_TOKEN="..."
export CODEXBAR_BEDROCK_BUDGET="250"
Resolve credentials from a named profile in ~/.aws/config / ~/.aws/credentials instead of pasting keys. Set the
profile name in Settings (or via AWS_PROFILE). CodexBar shells out to the AWS CLI
(aws configure export-credentials --profile <name>), so this works with SSO, assume-role,
credential_process, and MFA-cached profiles — not just static credentials.
Requirements:
PATH (CodexBar also checks /opt/homebrew/bin/aws, /usr/local/bin/aws, and ~/.local/bin/aws).
Override the location with AWS_CLI_PATH if it lives elsewhere.aws sso login --profile <name>). Credentials are resolved fresh on each
refresh; the AWS CLI caches the SSO token, so this does not re-prompt unless the session has expired.The profile's region is read automatically (aws configure get region); leave the Region field blank to use it, or set
AWS_REGION / the Region field to override.
Relevant environment variables:
export CODEXBAR_BEDROCK_AUTH_MODE="profile" # set automatically by Settings; "keys" or "profile"
export AWS_PROFILE="work"
export AWS_CLI_PATH="/opt/homebrew/bin/aws" # optional override
The AWS identity (from either mode) must have permission to call Cost Explorer APIs, including ce:GetCostAndUsage.
Grant cloudwatch:GetMetricData to add the optional Claude activity totals. Without that permission, cost and budget
tracking continue unchanged.
AWS_REGION or AWS_DEFAULT_REGION, defaulting to us-east-1.AWS/Bedrock
CloudWatch metrics. Other model families are excluded.CODEXBAR_BEDROCK_BUDGET, when set to a positive dollar amount.CODEXBAR_BEDROCK_API_URL replaces the Cost Explorer endpoint; use HTTPS or loopback HTTP.CODEXBAR_BEDROCK_CLOUDWATCH_API_URL replaces the CloudWatch endpoint; use HTTPS or loopback HTTP.codexbar --provider bedrock --source api
codexbar --provider bedrock --format json --pretty
ce:GetCostAndUsage.cloudwatch:GetMetricData in the configured
region.AWS_SESSION_TOKEN.AWS_CLI_PATH) and that the profile name is correct.The profile's SSO/temporary session has expired. Run aws sso login --profile <name> (or refresh the underlying
credentials) and retry.
Profile mode requires AWS CLI v2. Install it (e.g. brew install awscli) or point CodexBar at the binary with
AWS_CLI_PATH.
Set AWS_REGION or AWS_DEFAULT_REGION. Bedrock usage is regional, but Cost Explorer itself is account-level; CodexBar still needs a signing region for the request.
Sources/CodexBarCore/Providers/Bedrock/BedrockProviderDescriptor.swiftSources/CodexBarCore/Providers/Bedrock/BedrockSettingsReader.swiftSources/CodexBarCore/Providers/Bedrock/BedrockProfileCredentialProvider.swiftSources/CodexBarCore/Providers/Bedrock/BedrockUsageStats.swiftSources/CodexBarCore/Providers/Bedrock/BedrockAWSSigner.swift