|
| 1 | +--- |
| 2 | +title: 'Fine-tuning cost management' |
| 3 | +titleSuffix: Azure OpenAI |
| 4 | +description: Learn about cost management |
| 5 | +manager: nitinme |
| 6 | +ms.service: azure-ai-openai |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 07/08/2025 |
| 9 | +author: mrbullwinkle |
| 10 | +ms.author: mbullwin |
| 11 | +show_latex: true |
| 12 | +--- |
| 13 | + |
| 14 | +# Cost Management for Fine Tuning |
| 15 | + |
| 16 | +Fine tuning can be intimidating: unlike base models, where you're just paying for input and output tokens for inferencing, fine tuning requires training your custom models and dealing with hosting. This guide is intended to help you better understand the costs of fine tuning and how to manage them. |
| 17 | + |
| 18 | +## Upfront investment - training your model |
| 19 | + |
| 20 | +This is the one-time, fixed cost associated with teaching a base model your specific requirements using your training data. |
| 21 | + |
| 22 | +### The calculation formula |
| 23 | + |
| 24 | +**Supervised Fine Tuning (SFT) & Preference Fine Tuning (DPO)** |
| 25 | + |
| 26 | +It's straightforward to estimate the costs for SFT & DPO: you are charged based on the number of tokens in your training file, and the number of epochs for your training job. |
| 27 | + |
| 28 | +$$ |
| 29 | +\text{price} = \# \text{training tokens} \times \# \text{epochs} \times \text{price per token} |
| 30 | +$$ |
| 31 | + |
| 32 | +In general, smaller models and more recent models have lower prices per token than larger, older models. To estimate the number of tokens in your file, you can use the tiktoken library – or, for a less precise estimate, one word is roughly equivalent to four tokens. |
| 33 | + |
| 34 | +We offer both regional and global training for SFT; if you don't need data residency, global training allows you to train at a discounted rate. |
| 35 | + |
| 36 | +We do not charge you for time spent in queue, failed or cancelled jobs, or data safety checks. |
| 37 | + |
| 38 | +#### Worked example: Supervised Fine Tuning |
| 39 | + |
| 40 | +Projecting the costs to fine tune a model for natural language to code. |
| 41 | + |
| 42 | +- Prepare the training data file: 500 prompt / response pairs, with a total of 1M tokens, and a validation file with 20 examples and 40K tokens |
| 43 | +- Configure training run: |
| 44 | + - select base model (GPT-4.1) |
| 45 | + - specify global training |
| 46 | + - set hyperparameters to "default". Algorithmically, training is set to 2 epochs. |
| 47 | +- Training runs for 2 hours, 15 minutes |
| 48 | +**Total cost**: |
| 49 | +`$2/1M tokens * 1M training tokens * 2 epochs = $4` |
| 50 | + |
| 51 | +### Reinforcement Fine Tuning (RFT) |
| 52 | + |
| 53 | +The cost is determined by the time spent on training the model for Reinforcement fine tuning technique. |
| 54 | + |
| 55 | +#### The formula is: |
| 56 | + |
| 57 | +``` |
| 58 | +price = Time taken for training ⋅ Hourly training price + Grader inferencing per token if model grader is used |
| 59 | +``` |
| 60 | + |
| 61 | +- **Time**: Total time in hours rounded to two decimal places (e.g., 1.25 hours) |
| 62 | +- **Hourly Training cost**: $100 per hour of core training time for o4-mini-2025-04-16 |
| 63 | +- **Model grading**: Tokens used to grade outputs during training are billed separately at datazone rates once training is complete. |
| 64 | + |
| 65 | +#### Worked Example: Training model with graders (without Model grader – Score_model) |
| 66 | + |
| 67 | +Let's project the cost to train a customer service chatbot. |
| 68 | + |
| 69 | +- Submit fine tuning job: Time when FT job has submitted: 02:00 hrs |
| 70 | +- Data pre-processing completed: It took 30mins for data pre-processing to be completed which includes data safety checks. This time is not used for billing. |
| 71 | +- Training started: Training starts at 02:30 hours |
| 72 | +- Training completed: Training is completed at 06:30 hours |
| 73 | +- Model creation: A deployable model checkpoint is created after training completion which included post-training model safety steps. This time is not used for billing. |
| 74 | + |
| 75 | +**Final Calculation**: |
| 76 | +`Total time taken for training * Hourly training cost = 4 * 100 = $200` |
| 77 | + |
| 78 | +Your one-time investment to create this o4-mini custom fine tuned model would be **$400.00**. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +#### Worked Example: Training model with Model ‘Score_model’ grader (o3-mini being used as grader) |
| 83 | + |
| 84 | +Let's project the cost to train a customer service chatbot. |
| 85 | + |
| 86 | +- Submit fine tuning job: Time when FT job has started say 02:00 hrs |
| 87 | +- Data pre-processing completed: It took 30mins for data pre-processing to be completed which includes data safety checks. This time is not used for billing. |
| 88 | +- Training started: Training starts at 02:30 hours |
| 89 | +- Training completed: Training is completed at 06:30 hours |
| 90 | +- Model grader pricing: |
| 91 | + - Total Input tokens used for grading – 5 M tokens |
| 92 | + - Total Output tokens used for grading – 4.9 M tokens |
| 93 | +- Model creation: A deployable model checkpoint is created after training completion which included post-training model safety steps. This time is not used for billing. |
| 94 | + |
| 95 | +**Final Calculation**: |
| 96 | + |
| 97 | +``` |
| 98 | +Total time taken for training * Hourly training cost = 4 * 100 = $400 |
| 99 | +Grading costs = # Input tokens * Price per i/p token + Output tokens * price per o/p token |
| 100 | += (5 * 1.1) + (4.9 * 4.4) = 5.5 + 21.56 = $27.06 |
| 101 | +Total training costs = $427.06 |
| 102 | +``` |
| 103 | + |
| 104 | +Your one-time investment to create this o4-mini custom fine tuned model would be **$427.06** |
| 105 | + |
| 106 | +### Managing costs and spend limits when using RFT |
| 107 | + |
| 108 | +To control your spend we recommend: |
| 109 | + |
| 110 | +- Start with shorter runs to understand how your configuration affects time – Use configuration ‘reasoning effort’ – Low, smaller validation data sets |
| 111 | +- Use a reasonable number of validation examples and ‘eval_samples’. Avoid validating more often than you need. |
| 112 | +- Choose the smallest grader model that meets your quality requirements. |
| 113 | +- Adjust ‘compute_multiplier’ to balance convergence speed and cost. |
| 114 | +- Monitor your run in the Foundry portal or via the API. You can pause or cancel at any time. |
| 115 | + |
| 116 | +As RFT job can lead to high training costs, we are capping the pricing for per training job billing to **$5000** which means this will be the maximum amount that a job can cost before we end the job. The training will be paused and a deployable checkpoint will be created. Users can validate the training job, metrics, logs and then decide to resume the job to complete further. If the user decides to resume the job, billing will continue for the job and subsequently no further price limits would be placed on the training job. |
| 117 | + |
| 118 | +### Job failures and cancellations |
| 119 | + |
| 120 | +You are not billed for work lost due to our error. If you cancel a run, you'll be charged for the work completed up to that point. |
| 121 | +Example: the run trains for 2 hours, writes a checkpoint, trains for 1 more hour, but then fails. Only the 2 hours of training up to the checkpoint are billable. |
| 122 | + |
| 123 | +### Waiting on resources |
| 124 | + |
| 125 | +If job is queued |
| 126 | + |
| 127 | +### Part 2: Ongoing Operational Costs – Using Your Model |
| 128 | + |
| 129 | +After your model is trained, you can deploy it any number of times using the following deployment types: |
| 130 | + |
| 131 | +We have three options for hosting: |
| 132 | + |
| 133 | +- **Standard**: pay per-token at the same rate as base model Standard deployments with an additional $1.70/hour hosting fee. Offers a 99.9% availability SLA and regional data residency guarantees. |
| 134 | +- **Global Standard**: pay per-token at the same rate as base model Global Standard deployments with an additional $1.70/hour hosting fee. Offers a 99.9% availability SLA but does not offer data residency guarantees. Offers higher throughputs than Standard deployments. |
| 135 | +- **Regional Provisioned Throughput**: offers latency guarantees in addition to the availability SLA, designed for latency-sensitive workloads. Instead of paying per-token or an hourly hosting fee, deployments accrue PTU-hours based on the number of provisioned throughput units (PTU) assigned to the deployment, and billed at a rate determined by your agreements or reservations with Microsoft Azure. |
| 136 | +- **Developer Tier (Public Preview)**: pay per-token and without an hourly hosting fee but offers neither data residency nor availability SLAs. Designed for model candidate evaluation and proof of concepts, deployments are removed automatically after 24 hours regardless of usage but may be redeployed as needed. |
| 137 | + |
| 138 | +The right deployment type for your use case depends on weighing your AI requirements and where you are on your fine-tuning journey. |
| 139 | + |
| 140 | +| Deployment Type | Availability SLA | Latency SLA | Token Rate | Hourly Rate | |
| 141 | +|----------------------------|------------------|-------------|--------------------|-----------------| |
| 142 | +| Standard | 99.9% | None | Same as base model | $1.70/hour | |
| 143 | +| Global Standard | 99.9% | None | Same as base model | $1.70/hour | |
| 144 | +| Regional Provisioned Throughput | 99.9% | Same as base model | None | PTU/hour | |
| 145 | +| Developer Tier | None | None | Same as Global Standard | None | |
| 146 | + |
| 147 | +Pricing Structure for all models are called out in the Pricing page - Azure OpenAI Service - Pricing |
| 148 | +Microsoft Azure |
| 149 | + |
| 150 | +### Example for o4-mini |
| 151 | + |
| 152 | +- Hosting charges: $1.70 per hour |
| 153 | +- Input Cost: $1.10 per 1M tokens |
| 154 | +- Output Cost: $4.40 per 1M tokens |
| 155 | + |
| 156 | +#### Worked Example: Monthly Usage of a Fine-Tuned Chatbot |
| 157 | + |
| 158 | +Let's assume your chatbot handles 10,000 customer conversations in its first month: |
| 159 | + |
| 160 | +- Hosting charges: $1.70 per hour |
| 161 | +- Total Input: The user queries sent to the model total 20 million tokens. |
| 162 | +- Total Output: The model's responses to users total 40 million tokens. |
| 163 | + |
| 164 | +**Input Cost Calculation**: |
| 165 | +`20 × $1.10 = $22.00` |
| 166 | + |
| 167 | +**Output Cost Calculation**: |
| 168 | +`40 × $4.40 = $176.00` |
| 169 | + |
| 170 | +**Your total operational cost for the month would be**: |
| 171 | +`= Hosting charges + Token usage cost` |
| 172 | +`= ($1.70 * 30 days * 24 hours) + ($22 (Input) + $176 (Output))` |
| 173 | +`= $1422.00` |
0 commit comments