Learn how to track and analyze costs for specific AI models in your Pika deployment using AWS Cost Explorer and inference profiles.
What You'll Accomplish
Section titled “What You'll Accomplish”By the end of this guide, you will:
- Understand how Pika enables model-level cost tracking
- Find inference profile costs in AWS Cost Explorer
- Filter and analyze costs by model, environment, and tags
- Create cost allocation reports for budgeting and forecasting
Prerequisites
Section titled “Prerequisites”- Pika backend stack deployed to AWS
- Access to AWS Cost Explorer in your account
- Basic understanding of AWS cost management
How Pika Enables Model Cost Tracking
Section titled “How Pika Enables Model Cost Tracking”Pika automatically creates named inference profiles by copying AWS's built-in Bedrock inference profiles. This allows you to:
- Track costs for specific models (e.g., Claude 4.5 Sonnet vs Claude 4.5 Haiku)
- Differentiate costs between environments (dev vs prod)
- Allocate AI costs to projects, teams, or cost centers
What Are Inference Profiles?
Section titled “What Are Inference Profiles?”Inference profiles are named wrappers around base Bedrock models. They:
- Function identically to the base models
- Enable granular cost tracking in AWS Cost Explorer
- Are automatically created during deployment
- Are tagged with your configured stack tags
Step 1: Understand Your Inference Profile Names
Section titled “Step 1: Understand Your Inference Profile Names”Before searching for costs, you need to know your inference profile names.
Naming Pattern
Section titled “Naming Pattern”Inference profiles follow this pattern:
{stackName}-{profileName}Where:
- stackName = Your
pika.projNameKebabCase+ stage (e.g.,pika-test,customer-api-prod) - profileName = Model identifier (e.g.,
claude-sonnet-4-5,claude-haiku-4-5)
Find Your Stack Name
Section titled “Find Your Stack Name”Check your pika-config.ts:
export const pikaConfig: PikaConfig = { pika: { projNameKebabCase: 'pika', // This is your base name // ... }};Add your deployment stage:
- If deployed with
STAGE=test: stack name ispika-test - If deployed with
STAGE=prod: stack name ispika-prod
Current Profile Names
Section titled “Current Profile Names”Pika creates three inference profiles per deployment:
| Model | Profile Name Suffix |
|---|---|
| Claude 4 Sonnet | claude-sonnet-4 |
| Claude 4.5 Haiku | claude-haiku-4-5 |
| Claude 4.5 Sonnet | claude-sonnet-4-5 |
Example for STAGE=test:
pika-test-claude-sonnet-4pika-test-claude-haiku-4-5pika-test-claude-sonnet-4-5
Step 2: Access AWS Cost Explorer
Section titled “Step 2: Access AWS Cost Explorer”Navigate to AWS Cost Explorer:
- Sign in to the AWS Management Console
- Go to Billing and Cost Management
- Click Cost Explorer in the left navigation
Select Date Range:
- Choose a date range that includes your deployment
- Recommendation: Start with "Last 30 days" to see recent costs
Step 3: Filter by Inference Profile Name
Section titled “Step 3: Filter by Inference Profile Name”Option A: Filter by Service (Recommended)
Section titled “Option A: Filter by Service (Recommended)”Filter by AWS Bedrock:
- Click Filters → Service
- Search for and select "Amazon Bedrock"
Group by Usage Type:
- Click Group by → Usage Type
- Look for entries containing your inference profile names
- Example:
USE2-Inference:pika-test-claude-sonnet-4-5
Identify Your Costs:
- Usage types will include your inference profile names
- Costs are displayed per profile
Option B: Filter by Tags
Section titled “Option B: Filter by Tags”If you've configured stack tags, use them for more flexible filtering:
Filter by Project Tag:
- Click Filters → Tag
- Select your project tag key (e.g.,
Project) - Choose the value (e.g.,
CustomerPortal)
Add Service Filter:
- Add Service filter → Amazon Bedrock
Group by Component:
- Click Group by → Tag
- Select
componenttag - This shows costs per inference profile
Step 4: Analyze Costs by Model
Section titled “Step 4: Analyze Costs by Model”View Costs Per Model
Section titled “View Costs Per Model”Create a custom view to compare model costs:
Group by Usage Type:
- Set Group by → Usage Type
- Filter to show only Bedrock costs
Filter by Inference Profile Pattern:
- Look for usage types containing your stack name
- Each model will appear as a separate line
Compare Costs:
- Identify which models are most expensive
- Analyze usage patterns over time
Example Analysis
Section titled “Example Analysis”For a project with stack name customer-api-prod:
| Usage Type | Monthly Cost | Percentage |
|---|---|---|
Inference:customer-api-prod-claude-sonnet-4-5 | $450.23 | 65% |
Inference:customer-api-prod-claude-haiku-4-5 | $180.15 | 26% |
Inference:customer-api-prod-claude-sonnet-4 | $62.08 | 9% |
Insights:
- Claude 4.5 Sonnet accounts for 65% of AI costs
- Consider using Claude 4.5 Haiku for simpler queries
- Claude 4 Sonnet has minimal usage
Step 5: Compare Costs Across Environments
Section titled “Step 5: Compare Costs Across Environments”Use tags to compare dev vs production costs:
Filter by Environment Tag:
- Click Filters → Tag → Environment
- Select multiple values (e.g.,
dev,prod)
Group by Environment:
- Click Group by → Tag: Environment
Add Model Grouping:
- Enable secondary grouping: Usage Type
Analyze Differences:
- Compare dev vs prod spending
- Identify opportunities to reduce dev costs
- Ensure prod has appropriate budget allocation
Cost Optimization Patterns
Section titled “Cost Optimization Patterns”Development Environment:
- Higher percentage of Haiku usage (lower cost)
- Burst patterns (testing phases)
- Candidate for auto-scaling down during off-hours
Production Environment:
- More Sonnet usage (higher quality responses)
- Consistent usage patterns
- Requires stable performance and availability
Step 6: Create Cost Allocation Reports
Section titled “Step 6: Create Cost Allocation Reports”Build custom reports for stakeholders:
Monthly AI Cost Report
Section titled “Monthly AI Cost Report”Configure Report:
- Date range: Last 3 months
- Service: Amazon Bedrock
- Group by: Tag (Project), then Usage Type
Save Report:
- Click Save as... → New report
- Name: "AI Model Costs - Monthly"
- Set frequency: Monthly
Share:
- Export to CSV for stakeholders
- Create budget alerts based on trends
Model Efficiency Report
Section titled “Model Efficiency Report”Track cost per model over time:
Configure View:
- Date range: Last 90 days
- Chart type: Line chart
- Group by: Usage Type (inference profiles)
Identify Trends:
- Seasonal usage patterns
- Cost increases after feature launches
- Optimization opportunities
Step 7: Set Up Cost Alerts
Section titled “Step 7: Set Up Cost Alerts”Create budgets and alerts for AI spending:
Navigate to AWS Budgets:
- Go to Billing → Budgets
- Click Create budget
Configure Budget:
- Budget type: Cost budget
- Scope: Amazon Bedrock service
- Filter by tags (optional): Project, Environment
Set Thresholds:
- Example: $1,000/month for production AI costs
- Alert at 80% and 100% of budget
- Send notifications to team email
Add Forecasting:
- Enable forecasted alerts
- Get warnings before exceeding budget
Common Cost Analysis Patterns
Section titled “Common Cost Analysis Patterns”By Project
Section titled “By Project”Track AI costs per project:
Filter: Tag:Project = "CustomerPortal"Service: Amazon BedrockGroup by: Tag:component (inference profile)Date range: Last 30 daysBy Team
Section titled “By Team”Allocate costs to teams:
Filter: Tag:Team = "platform"Service: Amazon BedrockGroup by: Usage TypeDate range: Month to dateBy Environment
Section titled “By Environment”Compare environments:
Filter: Service = Amazon BedrockGroup by: Tag:Environment, then Usage TypeDate range: Last 7 daysModel Comparison
Section titled “Model Comparison”Compare specific models:
Filter: Service = Amazon BedrockFilter: Usage Type contains "claude-sonnet"Group by: Usage TypeDate range: Last 90 daysChart: Line chartCost Optimization Tips
Section titled “Cost Optimization Tips”Use Appropriate Models
Section titled “Use Appropriate Models”- High-stakes queries: Claude 4.5 Sonnet (higher quality, higher cost)
- Simple queries: Claude 4.5 Haiku (good quality, lower cost)
- Bulk processing: Claude 4 Sonnet or Haiku (older, less expensive)
Monitor Usage Patterns
Section titled “Monitor Usage Patterns”- Identify peak usage times
- Consider batch processing for non-urgent tasks
- Review agent configurations for unnecessary model calls
Environment-Specific Strategies
Section titled “Environment-Specific Strategies”Development:
- Default to less expensive models
- Use cheaper models for testing
- Implement auto-shutdown for after-hours
Production:
- Balance quality and cost
- Set up cost anomaly detection
- Review usage weekly
Tag Consistently
Section titled “Tag Consistently”Proper tagging enables better cost analysis:
- Always use consistent tag keys
- Include Environment, Project, and Team tags
- Document your tagging strategy
Troubleshooting
Section titled “Troubleshooting”Inference Profiles Not Appearing in Cost Explorer
Section titled “Inference Profiles Not Appearing in Cost Explorer”Problem: Can't find inference profile costs in Cost Explorer
Solutions:
Verify profiles were created:
- Check AWS Bedrock console → Inference profiles
- Look for profiles matching your naming pattern
Wait for cost data:
- Cost data can take 24-48 hours to appear
- Recent deployments may not show costs yet
Check date range:
- Ensure Cost Explorer date range includes deployment date
- Costs only appear after actual model usage
Tags Not Showing in Cost Explorer
Section titled “Tags Not Showing in Cost Explorer”Problem: Configured tags aren't available for filtering
Solutions:
Activate cost allocation tags:
- Go to Billing → Cost allocation tags
- Find and activate your tags
- Wait up to 24 hours for activation
Verify tag application:
- Check inference profile in Bedrock console
- Confirm tags are present on resources
Check tag format:
- Ensure tags don't start with
aws:orcloudformation: - These system tags are automatically filtered out
- Ensure tags don't start with
Unexpected High Costs
Section titled “Unexpected High Costs”Problem: AI costs are higher than expected
Investigation Steps:
Identify high-cost profiles:
- Group by Usage Type in Cost Explorer
- Find which model is most expensive
Check usage volume:
- Review application logs
- Identify high-volume agents or queries
Analyze usage patterns:
- Look for unexpected spikes
- Check for inefficient agent configurations
Best Practices
Section titled “Best Practices”- Review costs weekly - Catch anomalies early
- Tag consistently - Enable flexible cost analysis
- Set up alerts - Get notified of budget overruns
- Document naming - Maintain a record of inference profile names
- Share reports - Keep stakeholders informed of AI costs
- Optimize continuously - Review and adjust model usage based on cost data
Next Steps
Section titled “Next Steps”- Configure AWS Resource Tags - Enhance cost tracking with tags
- Inference Profile Names - Complete naming reference
- Stack Tags Configuration - Configure stack tags for better cost allocation
See Also
Section titled “See Also”- AWS Cost Explorer Documentation - AWS official guide
- Cost Allocation Tags - Tag activation guide
- AWS Budgets - Set up cost alerts