Google Translate usage limits

934 views
Skip to first unread message

Hye Ji Moon

unread,
Jul 4, 2022, 10:43:36 AM7/4/22
to Google Cloud Translation API
Hi. 
We are trying to use Google Translate javascript API down below.

<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> 
<script type="text/javascript">function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'},'google_translate_element');}</script>


We are aware of that Google Translate API and Google Cloud Translation API is two  different things. and try to find out details about Google Translate API.

I have questions for using Google Translate API here:  
1. Can we use Google Translate Api without any use Limits?
2. If we need to pay for using Google Translate Api, where can we find the guide for paying?

Thank you
 
Regards 
Alex Moon

Raul Saucedo Ramirez

unread,
Jul 5, 2022, 1:53:49 PM7/5/22
to Google Cloud Translation API
  1. There are no limits of request to translate text(text translation) and Detect Language (language detection). However, these limits cannot be changed.

           Maximum number of files that you can include in a single batch request             100 files

          Maximum number of glossary resources for a project                                              10,000

       2. You are charged for Cloud Translation based on monthly usage. You can see this link.

Hye Ji Moon

unread,
Jul 8, 2022, 5:14:49 PM7/8/22
to Google Cloud Translation API
Hi Expert

Thank you for your support, however I assume that you answered is about Google Cloud Translation API.

what I really want to know is there are any limits for using Google Translate "javascript" API down below.
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

1. Do I understand right that There're no limits of using Google Translate "javascript" API Unless we use file translation and glossary resources?
2. also, Could you let us know where we can find the guide for Google Translate "javascript" API ?

Thank you so much.
Regards 
Alex Moon

2022년 7월 6일 수요일 오전 2시 53분 49초 UTC+9에 saucedo...@google.com님이 작성:

Manuel Souto Pico

unread,
Jul 11, 2022, 1:08:01 PM7/11/22
to Google Cloud Translation API
In case this helps:

I use the Google Translate API with python.

There seems to be a limit of 128 in the number of segments the API can process in one single batch.

Exceeding that limit results in error 'google.api_core.exceptions.BadRequest: 400 POST https://translation.googleapis.com/language/translate/v2?prettyPrint=false: Too many text segment'

To avoid that, what I do is to split the list of strings in batches of 100 segments, and post batches individually, and merge them afterwards.

number_of_segments = len(list_of_strings)
if number_of_segments > 100:
logging.info("Too many segments, it's necessary to split to avoid 'google.api_core.exceptions.BadRequest'.")
logging.info("Let's limit the number of segments per batch to 100")
num_of_batches = math.ceil(number_of_segments / 100)
batches = np.array_split(list_of_strings, num_of_batches)
else:
batches = np.array_split(list_of_strings, 1)

Cheers, Manuel


--
You received this message because you are subscribed to the Google Groups "Google Cloud Translation API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-translate...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-translate-api/516c8d97-431c-4f23-951a-8127887041bfn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages