Skip to content

Instantly share code, notes, and snippets.

@airyland
Last active March 8, 2023 01:52
Show Gist options
  • Save airyland/1110aee75c17023e62c1c0cca126dfc5 to your computer and use it in GitHub Desktop.
Save airyland/1110aee75c17023e62c1c0cca126dfc5 to your computer and use it in GitHub Desktop.
ChatGPT Bill Caculator
// https://platform.openai.com/account/usage
// Run code in the console to avoid bankruptcy
var $labels = document.querySelectorAll('.usage-table .expn-title .expn-icon')
$labels[0].click()
var $items = document.querySelectorAll('.expn.expanded .expn-content .expn-icon')
for (let i = 0; i < $items.length; i++) {
$items[i].click()
}
var $sum = document.querySelectorAll('.sum')
let count = 0
for (let i = 0; i < $sum.length; i++) {
const _count = $sum[i].innerText.replace('tokens', '').replace(/,/g, '').trim()
count += _count * 1
}
console.log('Date:', document.querySelector('.usage-day-select').innerText)
console.log('Tokens:', count)
console.log('Bill:', '$' + new Intl.NumberFormat().format(count / 1000 * 0.002))
@airyland
Copy link
Author

airyland commented Mar 6, 2023

@yunyu950908 这个数据是滞后的。turbo model 每天调用的费用并没有计算出来。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment