Hi Vikas Sharma,
Welcome to Microsoft Q&A and Thank you for reaching out.
It looks like you want to know how to accurately count characters and estimate costs when using the Microsoft Translator API. Here’s a breakdown of how you can achieve that.
Character Count
- Character Counting Method: Azure Translator counts every code point defined in Unicode as a character, which includes:
- The text passed in the request.
- HTML and XML tags.
- Individual letters, punctuation, spaces, and any white-space characters.
- Each translation counts as a separate transaction, even if you translate the same text multiple times.
- Getting Sentence Lengths:
- You can obtain character counts for source text and translation using the
translateendpoint by setting theincludeSentenceLengthparameter toTrue. This will return the character count for each sentence detected. - To get sentence lengths without translating, you can use the
breaksentenceendpoint, which simply provides the character count for the source text.
- You can obtain character counts for source text and translation using the
Cost Estimation
- Character-Based Billing: Costs are based on character count, not requests. Each translation request has a cap of 50,000 characters. For example, translating 3,000 characters into three different languages would count as 9,000 characters.
- Subscription Character Limits:
- Free Tier (F0): 2 million characters per month.
- Standard Tier (S1): 40 million characters per hour.
- There are higher tiers available that allow for more characters, which might be beneficial if you do extensive translations.
Resources
- You can refer to these documents for more comprehensive guidance:
I Hope this helps. Do let me know if you have any further queries.
If this answers your query, please do click Accept Answer and Yes for was this answer helpful.
Thank you!