Fine-Tuning Calculator

This calculator tells you if fine-tuning or prompting is more expensive.
Let's assume you were using GPT 4 for basic prompting, and with fine-tuning, you're now using GPT 3.5 Turbo.
”If you can achieve good results with GPT-4, you can often reach similar quality with a fine-tuned gpt-3.5-turbo model by fine-tuning on the GPT-4 completions, possibly with a shortened instruction prompt.”
According to the OpenAI Pricing Page, the cost of regular prompting is:
$0.0015 / 1K input tokens
$0.002 / 1K output tokens
The cost of fine-tuning is:
$0.008 / 1K training tokens
$0.012 / 1K input tokens
$0.016 / 1K output tokens
Savings using Fine Tuning:
$2,487.67
Basic Prompting
$3,000.00
$120.00
$3,120.00
Fine Tuning
$0.33
$600.00
$32.00
$632.33
Formula
BASIC_INPUT_COST = 0.03 / 1000
BASIC_OUTPUT_COST = 0.06 / 1000
FT_TRAINING_COST = 0.008 / 1000
FT_INPUT_COST = 0.012 / 1000
FT_OUTPUT_COST = 0.016 / 1000
NUM_EPOCHS = 4 (default number of epochs)
basicInputCost = (systemPromptTokenCount + userPromptTokenCount) * BASIC_INPUT_COST * runCount
basicOutputCost = outputTokenCount * BASIC_OUTPUT_COST * runCount
basicTotalCost = basicInputCost + basicOutputCost;
fineTuningTrainingCost = (systemPromptTokenCount + userPromptTokenCount + outputTokenCount) * FT_TRAINING_COST * examplesInFineTuningCount * NUM_EPOCHS
fineTuningInputCost = userPromptTokenCount * FT_INPUT_COST * runCount
fineTuningOutputCost = outputTokenCount * FT_OUTPUT_COST * runCount
fineTuningTotalCost = fineTuningTrainingCost + fineTuningInputCost + fineTuningOutputCost;