Hello Nojus Dziaugys,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are asking why content safety input tokens are so expensive and how to minimize them.
This issue typically stems from how Azure bills for Content Safety not by OpenAI-style tokens, but by text records, each representing up to 1,000 Unicode characters. If your inputs are long or untrimmed, they can easily multiply into several records per request, driving up costs. According to Azure's pricing, the Standard tier charges $0.38 per 1,000 records, and all safety filters (hate, violence, sexual, self-harm) are applied unless explicitly customized.
To track what’s consuming these records, you should wrap the Content Safety API with Azure API Management (APIM). This allows you to apply <llm-emit-token-metric> and <llm-token-limit> policies to monitor and control usage. You can then route diagnostics to Azure Monitor or Log Analytics, where you can query usage with KQL like:
AzureDiagnostics
| where Resource == "apim-content-safety"
| project TimeGenerated, clientIP, consumedTokens, remainingTokens, apiName
This setup helps visualize usage per department, model, or client IP, and can be extended into dashboards using Azure Monitor Workbooks or Power BI. For implementation guidance, refer to this APIM integration guide.
To reduce costs, start by trimming input size remove boilerplate, disclaimers, or irrelevant metadata before sending content. Also, batch short texts into single requests where possible, and disable unnecessary filters if your use case doesn’t require all four categories. For repeated content, implement caching to avoid redundant checks. You can also enforce quotas using <llm-token-limit> to prevent overuse by specific clients or departments.
If you're testing or prototyping, consider using the free tier, which offers 5,000 records per month at no cost. However, if your usage pattern still results in 10x higher costs, it's a strong signal to audit your integration and optimize both payload design and filter configuration.
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.