#!/usr/bin/env python3
"""Google Gemini 4 Argon token-only budget, rates checked 2026-10-14.
I includes C. O includes thinking. No API calls. Does not parse raw usage events.
Excludes tools (including Search/Maps), taxes, FX and subscription fees.
"""
import argparse
from decimal import Decimal
RATES={'standard':('2','.1','10'),'batch':('1','.05','5'),'flex':('1','.05','5'),'priority':('3.6','.18','18')}
def cost(input_tokens, cached_tokens, output_tokens, tier='standard', period='promo'):
    if any(not isinstance(x,int) or isinstance(x,bool) or x<0 for x in [input_tokens,cached_tokens,output_tokens]):
        raise ValueError('Token counts must be nonnegative integers')
    if cached_tokens>input_tokens: raise ValueError('Cached tokens cannot exceed total input')
    if period not in ('promo','regular'): raise ValueError('Unknown price period')
    pi,pc,po=map(Decimal,RATES[tier]);factor=1 if period=='promo' else 2
    return ((input_tokens-cached_tokens)*pi+cached_tokens*pc+output_tokens*po)*factor/Decimal(1000000)
if __name__=='__main__':
    p=argparse.ArgumentParser(description=__doc__)
    p.add_argument('--input',required=True,type=int);p.add_argument('--output',required=True,type=int)
    p.add_argument('--cached',type=int,default=0);p.add_argument('--tier',choices=RATES,default='standard')
    p.add_argument('--period',choices=['promo','regular'],required=True,help='promo through 2026-11-30; regular from 2026-12-01')
    a=p.parse_args()
    try: result=cost(a.input,a.cached,a.output,a.tier,a.period)
    except ValueError as e:p.error(str(e))
    print(f'{result:.6f} USD')
    print('Token-only estimate. Excludes Search/Maps/other tools, taxes, FX and subscriptions. Input includes cached; output includes thinking. Rates checked 2026-10-14.')
