JJoeven

Exercises / llm

Estimate USD cost

cost(in_tokens, out_tokens, in_rate=0.5, out_rate=1.5) uses rates per 1M tokens. Print cost for 2000 in and 400 out, rounded to 6 decimals.

Live Pythonpython
Output
Run to execute this in your browser. Nothing is sent to a server.