Advertisement
Guest User

Claude cache pricing

a guest
Nov 19th, 2024
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. PRICE_IN = 3 / 1000000
  2. PRICE_OUT = 15 / 1000000
  3. PRICE_CACHE_WRITE = PRICE_IN * 1.25
  4. PRICE_CACHE_READ = PRICE_IN * .1
  5.  
  6. def total_tk_in(start, input, output, turns):
  7.     total = 0
  8.     next = start + input
  9.     for i in range(turns):
  10.         total += next
  11.         next += output + input
  12.     return total
  13.  
  14. def total_tk_out(output, turns):
  15.     return output * turns
  16.  
  17. def price_full(input, output):
  18.     return input * PRICE_IN + output * PRICE_OUT
  19.  
  20. def price_cache(start, input, output, turns, total_in, total_out):
  21.     cache_write_tk = (start + input * turns + output * (turns-1))
  22.     cache_write = cache_write_tk * PRICE_CACHE_WRITE
  23.     cache_read_tk = total_in - cache_write_tk
  24.     cache_read = cache_read_tk * PRICE_CACHE_READ
  25.     price_output = total_out * PRICE_OUT
  26.     total = cache_write + cache_read + price_output
  27.     return total
  28.  
  29. for j in [2000, 8000, 20000]:
  30.     for i in [1,2,3,6,12]:
  31.         x = total_tk_in(j, 20, 170, i)
  32.         y = total_tk_out(170, i)
  33.         price = price_full(x,y)
  34.         price_cached = price_cache(j, 20, 170, i, x, y)
  35.         discount = (1 - price_cached / price) * 100
  36.         print("{}, {}, {:.4f}, {:.4f}, {:.0f}%".format(x,y,price,price_cached,discount))
  37.     print()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement