Skip to content

Instantly share code, notes, and snippets.

@mikamboo
Last active October 31, 2025 08:24
Show Gist options
  • Select an option

  • Save mikamboo/afd98fb78c3ada58b56acfd38dd342f3 to your computer and use it in GitHub Desktop.

Select an option

Save mikamboo/afd98fb78c3ada58b56acfd38dd342f3 to your computer and use it in GitHub Desktop.
AWS Pricing API for Bedrock models pricing

Querying Amazon Bedrock Pricing

This quick guide shows how to use the AWS Pricing API via the AWS CLI to retrieve Amazon Bedrock on‑demand inference prices for Anthropic models (e.g., Claude). It includes a ready-to-run example that filters by provider, region, feature, and extracts usable price fields with jq.

Key points

  • Use the AWS Pricing API (aws pricing get-products) with --service-code "AmazonBedrock".
  • The Pricing API returns large JSON; use jq to parse and extract model, usage type, and USD price per unit.
  • The Pricing API is commonly queried from us-east-1 (--region us-east-1) because pricing data is centrally available there.
  • Attribute names can vary slightly across accounts/regions (e.g., model vs modelName, inferenceType capitalization). If a query returns nothing, first inspect attributes to confirm names.

Basic command: Anthropic On‑demand inference (region = US East - N. Virginia)

Copy/paste this one-liner. It filters for Anthropic + On‑demand Inference in the N. Virginia region and returns model, usageType, inferenceType, location, price per unit (USD) and unit:

aws pricing get-products \
  --service-code "AmazonBedrock" \
  --filters Type=TERM_MATCH,Field=provider,Value="Anthropic" \
            Type=TERM_MATCH,Field=feature,Value="On-demand Inference" \
            Type=TERM_MATCH,Field=location,Value="US East (N. Virginia)" \
  --region us-east-1 \
  --output json \
| jq -r '.PriceList[] 
    | fromjson 
    | .product.attributes as $a 
    | (.terms.OnDemand // {}) 
    | to_entries[]? 
    | .value.priceDimensions 
    | to_entries[]? 
    | {model:$a.model, provider:$a.provider, usageType:$a.usagetype, inferenceType:$a.inferenceType, location:$a.location, price_per_unit:.value.pricePerUnit.USD, unit:.value.unit}'

Example simplified one-liner (no line breaks):

aws pricing get-products --service-code "AmazonBedrock" --filters Type=TERM_MATCH,Field=provider,Value="Anthropic" Type=TERM_MATCH,Field=feature,Value="On-demand Inference" Type=TERM_MATCH,Field=location,Value="US East (N. Virginia)" --region us-east-1 --output json | jq -r '.PriceList[] | fromjson | .product.attributes as $a | (.terms.OnDemand // {}) | to_entries[]? | .value.priceDimensions | to_entries[]? | {model:$a.model,provider:$a.provider,usageType:$a.usagetype,inferenceType:$a.inferenceType,location:$a.location,price_per_unit:.value.pricePerUnit.USD,unit:.value.unit}'

Explanation:

  • --service-code "AmazonBedrock": Restricts to Bedrock pricing.
  • --filters Type=TERM_MATCH,Field=provider,Value="Anthropic": Only Anthropic models.
  • --filters Type=TERM_MATCH,Field=location,Value="US East (N. Virginia)": Set region as needed.
  • --filters Type=TERM_MATCH,Field=feature,Value="On-demand Inference": Only on-demand inference pricing.
  • Output is parsed with jq to show the model, usage type, inference type, and price.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment