Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 3amprogrammer/da17c845b9e99469ebb0ed0ae4d16b98 to your computer and use it in GitHub Desktop.
Save 3amprogrammer/da17c845b9e99469ebb0ed0ae4d16b98 to your computer and use it in GitHub Desktop.
Chat GPT estimation
const requestPrice = 0.003;
const responsePrice = 0.004;
const initialPromptSizeInTokens = 500;
const averageRequestTokens = 40;
const averageResponseTokens = 100;
const conversationTimeInMinutes = 15;
const messagesPerMinute = 2;
let totalConversationCost = 0;
let contextSizeTokens = 0;
for (let i = 0; i < conversationTimeInMinutes * messagesPerMinute; i++) {
contextSizeTokens += averageRequestTokens + averageResponseTokens;
const currentRequestPrice = (initialPromptSizeInTokens + averageRequestTokens + contextSizeTokens) / 1000 * requestPrice;
const currentResponsePrice = averageResponseTokens / 1000 * responsePrice;
totalConversationCost += currentRequestPrice + currentResponsePrice;
}
console.log(totalConversationCost);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment