In my last post I showed how to get started with Azure OpenAI, the service which is effectively "Microsoft-hosted ChatGPT" but also includes other OpenAI models. In particular I showed how to integrate ChatGPT with the Power Platform via a custom connector that talks to your instance in Azure. If you're doing anything with Azure OpenAI it's a good idea to monitor costs, particularly if the service will be open to a few consumers - it's not the cheapest Azure service, and costs could accumulate quickly in some usage patterns. The good news is that it is possible to monitor Azure OpenAI costs just like any other Azure service - this means using Azure Cost Management, and you just need to the right configuration to zero in on this service in particular. As with any Azure service it's not possible to put a hard limit in place by default - you could with some custom automation, but only if you implement that.
What you can do of course, is use Azure Cost Management to implement a Budget which will notify you when costs are passing defined thresholds. This can alert an operations team that consumption is higher than expected, at which point some investigation and/or intervention action can occur. With many Azure services this is better than shutting down production use, which would leave teams scrambling to work out why a critical process is not working.
This article focuses on how to put such a Budget and alerting mechanism in place.
Indeed, that's one of the benefits of using Microsoft's Azure OpenAI instead of the API provided by the OpenAI organisation - in addition to the service meeting all usual Azure standards related to security, support for private networking, regional support, and compliance, you can work with Azure OpenAI through regular Azure service conventions and management tools too.
Creating an Azure Budget to monitor Azure OpenAI costs
If you've ever created an Azure Budget to monitor another service, the process is no different - it's simply a question of finding the right filter for Azure OpenAI. An important note on this:
I provide valid filters you can use below.
Given the varying scopes a Budget can be created at, there are a couple of ways to do it. The process I outline below creates it at the subscription level (i.e. covering all resource groups in that sub) - but creating at the RG level or the overarching management group level are alternatives,
The process
We start by heading into Cost Management in the Azure portal, and then into 'Budgets'.
Once there, hit the 'Add' button to create a new one. The key step is to add a filter for one of the Azure OpenAI fields - in the image below I'm using MeterSubCategory = Azure OpenAI, but there are several possible options (detailed below):
How granularly do you want to manage costs? Filter options relevant to Azure OpenAI
Depending on how granular you want to get with monitoring specific Azure OpenAI usage, the following filter options could be used in your Azure Budget:
Filter | Effect |
---|---|
MeterSubCategory = 'Azure OpenAI' | Monitor all OpenAI usage |
Product = 'Azure OpenAI - Text-Davinci' | Monitor the specified model only (Text-Davinci in this case) |
Meter = 'Text-Davinci Tokens' | I believe filtering on this will allow you to monitor specified model consumption only (as opposed to model training, which would have a different value) |
Service Family = 'AI + Machine Learning' | [Slightly different but including for completeness] - this would allow you to monitor ALL AI usage, including Azure Cognitive Services |
Using Azure Cost Analysis to monitor OpenAI usage
Creating an Azure budget will help you become aware if costs are beyond what is expected (via the alerts), but sometimes you just want to do some ad-hoc analysis of what's happening. This can be done by heading into the 'Cost analysis' area:
Summary
Useful documentation pages
- Monitoring Azure OpenAI Service
- Plan to manage costs for Azure OpenAI Service
- (note this page currently has a small but important inaccuracy, since it suggests a filter of "Service tier: Azure OpenAI" but this doesn't align with the Budget filter options - use one of those in the table above instead)
No comments:
Post a Comment