Hello @Test Admin Thank you for posting your question on the Microsoft Q&A platform. Happy to answer any questions you may!
From the details shared in the original post, I understand that you have a requirement to fetch the monthly usage cost for GPT-turbo-instruct Model and Azure Speech-to-text. However, when tried to with tried with cost details API, it errored out with authentication failure message.
Regarding the "AuthenticationFailed" error you are receiving, it indicates that the API request is not being authenticated properly. Make sure that you are including the access token in the Authorization header of the API request.
To fetch the monthly usage billing cost of the GPT-turbo-instruct Model and Azure Speech-to-text resources from Azure using the Cost Details API, you can follow these steps:
- Obtain an Azure AD access token for authentication. You can use the Azure CLI or PowerShell to obtain the access token. Here is an example of how to obtain an access token using the Azure CLI: az account get-access-token --resource https://management.azure.com/
- Use the access token to authenticate the API request. Include the access token in the Authorization header of the API request.
- Use the Cost Details API to generate a cost details report for the specified time period and resource. Here is an example of how to generate a cost details report for the GPT-turbo-instruct Model resource:
POST https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-11-01
{
"metric": "ActualCost",
"timePeriod": {
"start": "YYYY-MM-DD",
"end": "YYYY-MM-DD"
},
"aggregation": {
"totalCost": {
"name": "TotalCost",
"function": "Sum"
}
},
"filter": {
"and": [
{
"dimension": {
"name": "ResourceGroup",
"operator": "In",
"values": [
"resource-group-name"
]
}
},
{
"dimension": {
"name": "Resource",
"operator": "In",
"values": [
"gpt-turbo-instruct-model"
]
}
}
]
}
}
- Replace the {subscription-id}, "YYYY-MM-DD", "resource-group-name", and "gpt-turbo-instruct-model" placeholders with the appropriate values for your environment.
- Repeat the above steps for the Azure Speech-to-text resource, replacing the "gpt-turbo-instruct-model" value with "azure-speech-to-text".
Hope this helps. Feel free to write back to us if you have any further queries.
If the response helped, do "Accept Answer" and up-vote it