Cost Attribution System

U

@

·

Build a comprehensive LLM cost attribution system with multi-dimensional tracking, budget alerts, and internal billing capabilities.

41 copies0 forks
Build a cost attribution system for LLM usage across teams and features.

## Organization Structure
{{org_structure}}

## LLM Usage Patterns
{{usage_patterns}}

## Attribution Requirements
{{attribution_requirements}}

Implement cost attribution:

```python
class CostAttributor:
    def track_request(self, request: LLMRequest, metadata: dict) -> None:
        """
        Metadata includes:
        - team_id
        - feature_id
        - user_id
        - environment
        """
        pass
    
    def calculate_costs(self, time_range: TimeRange, group_by: List[str]) -> CostReport:
        """Aggregate costs by dimensions"""
        pass
    
    def generate_invoice(self, team_id: str, period: str) -> Invoice:
        """Generate internal billing"""
        pass
```

Include:
- Token-level cost tracking
- Multi-model cost normalization
- Budget alerts
- Showback/chargeback reports
- Dashboard integration

Details

Category

Coding

Use Cases

Cost attributionUsage trackingInternal billing

Works Best With

claude-sonnet-4-20250514gpt-4o
Created Shared

Create your own prompt vault and start sharing