(model)
| 36 | } |
| 37 | |
| 38 | def get_pricing(model): |
| 39 | if not model: |
| 40 | return None |
| 41 | if model in PRICING: |
| 42 | return PRICING[model] |
| 43 | for key in PRICING: |
| 44 | if model.startswith(key): |
| 45 | return PRICING[key] |
| 46 | # Substring fallback: match model family by keyword |
| 47 | m = model.lower() |
| 48 | if "fable" in m or "mythos" in m: |
| 49 | return PRICING["claude-fable-5"] |
| 50 | if "opus" in m: |
| 51 | return PRICING["claude-opus-4-8"] |
| 52 | if "sonnet" in m: |
| 53 | return PRICING["claude-sonnet-4-6"] |
| 54 | if "haiku" in m: |
| 55 | return PRICING["claude-haiku-4-5"] |
| 56 | return None |
| 57 | |
| 58 | def calc_cost(model, inp, out, cache_read, cache_creation): |
| 59 | p = get_pricing(model) |
no outgoing calls