cost
The cost command lets you view and analyze cloud infrastructure costs directly from provider APIs. It fetches real cost data using your configured cloud credentials and supports multiple providers including AWS, GCP, Azure, and Cloudflare.
When invoked without a subcommand, cost defaults to showing a cost summary.
Usage
clanker cost [subcommand] [flags]Persistent Flags
These flags apply to all cost subcommands.
| Flag | Type | Default | Description |
|---|---|---|---|
--provider | string | all | Filter by cloud provider. Options: aws, gcp, azure, cloudflare, all |
--start | string | First of current month | Start date in YYYY-MM-DD format |
--end | string | Today | End date in YYYY-MM-DD format |
--format | string | table | Output format. Options: table, json |
--top | int | 10 | Maximum number of results to display |
--profile | string | From AWS_PROFILE env | AWS CLI profile to use for cost data retrieval |
Provider Support
| Provider | API Used | Status |
|---|---|---|
| AWS | Cost Explorer API | Available |
| GCP | Cloud Billing API | Coming soon |
| Azure | Cost Management API | Coming soon |
| Cloudflare | Analytics API | Coming soon |
Subcommands
cost summary
Display a summary of costs across all configured cloud providers. Shows total cost, per-provider breakdown, top services, and forecast data.
clanker cost summary [flags]Examples:
# Show cost summary for all providers
clanker cost summary
# Show only AWS costs
clanker cost summary --provider aws
# Show costs for a specific date range
clanker cost summary --start 2025-01-01 --end 2025-01-31
# Output as JSON
clanker cost summary --format json
# Use a specific AWS profile
clanker cost summary --provider aws --profile productioncost detail
Display a detailed cost breakdown by service. When a specific provider is selected, the output includes a full per-service itemization. When set to all, it shows top services across all providers.
clanker cost detail [flags]Examples:
# Show detailed breakdown for all providers
clanker cost detail
# Show AWS service-by-service breakdown
clanker cost detail --provider aws
# Show top 20 services in JSON format
clanker cost detail --top 20 --format json
# Detailed costs for a specific date range
clanker cost detail --provider aws --start 2025-02-01 --end 2025-02-28cost trend
Display daily cost trends over a specified time period. This is useful for spotting spending patterns, spikes, or gradual increases over time.
clanker cost trend [flags]Examples:
# Show cost trend for the current month
clanker cost trend
# Show cost trend for January 2025
clanker cost trend --start 2025-01-01 --end 2025-01-31
# Output trend data as JSON for further processing
clanker cost trend --format json
# Trend for AWS only
clanker cost trend --provider awscost forecast
Display cost forecasts for the remainder of the current month and the next month. Forecasts are generated by the cloud provider based on historical spending data.
clanker cost forecast [flags]TIP
AWS Cost Explorer forecast requires sufficient historical data to generate predictions. If your account is new or has limited usage history, forecast data may not be available.
Examples:
# Show cost forecast
clanker cost forecast
# Show forecast in JSON format
clanker cost forecast --format json
# Forecast for AWS only
clanker cost forecast --provider awscost anomalies
Display detected cost anomalies and potential waste. This subcommand highlights unusual spending patterns that may warrant investigation.
clanker cost anomalies [flags]Examples:
# Show detected anomalies
clanker cost anomalies
# Show anomalies in JSON format
clanker cost anomalies --format json
# Show anomalies for AWS only
clanker cost anomalies --provider awscost tags
Display costs grouped by resource tags. This is particularly useful for organizations that use tagging strategies to allocate costs by team, environment, project, or other dimensions.
clanker cost tags [flags]Additional Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--key | string | Environment | Tag key to group costs by |
Examples:
# Show costs grouped by the default "Environment" tag
clanker cost tags
# Show costs grouped by team
clanker cost tags --key Team
# Show costs grouped by project, output as JSON
clanker cost tags --key Project --format json
# Costs by tag for a specific date range
clanker cost tags --key Environment --start 2025-01-01 --end 2025-03-31cost export
Export cost data to a file. The format is automatically inferred from the file extension when --format is not explicitly set: .json files export as JSON, and all other extensions default to CSV.
clanker cost export [flags]Additional Flags
| Flag | Type | Default | Description |
|---|---|---|---|
--output | string | (required) | Output file path |
--group-by | string | provider | Grouping strategy. Options: provider, service, tag |
Examples:
# Export all costs to a CSV file
clanker cost export --output costs.csv
# Export as JSON
clanker cost export --output costs.json --format json
# Export AWS-only costs
clanker cost export --output aws-costs.csv --provider aws
# Export costs for a specific period, grouped by service
clanker cost export --output q1-costs.csv --start 2025-01-01 --end 2025-03-31 --group-by servicecost llm
Display LLM usage and cost information. Full LLM cost tracking requires the clanker-cloud backend to record per-request usage data. For AWS Bedrock model invocation costs, use clanker cost detail --provider aws instead, as those costs appear on your AWS bill.
clanker cost llm [flags]Examples:
# Show LLM usage and cost info
clanker cost llm
# Output as JSON
clanker cost llm --format jsonINFO
Bedrock costs appear on your AWS bill under service names such as "Claude Opus 4.5 (Amazon Bedrock Edition)" and "Claude Haiku 4.5 (Amazon Bedrock Edition)".
Authentication
The cost command uses your existing cloud provider credentials. For AWS, it relies on the AWS CLI profile configured in your clanker config or specified via the --profile flag. If neither is set, it falls back to the AWS_PROFILE environment variable.
Make sure your AWS credentials have permissions for the Cost Explorer API (ce:GetCostAndUsage, ce:GetCostForecast).
See Also
- Configuration -- Setting up cloud provider credentials
- profiles -- Listing available AWS profiles
- ask -- Querying infrastructure with natural language