Translates input text and returns translated text.
HTTP request
POST https://translate.googleapis.com/v3/{parent=projects/*/locations/*}:translateText
The URL uses gRPC Transcoding syntax.
Path parameters
Parameters | |
---|---|
parent |
Required. Project or location to make a call. Must refer to a caller's project. Format: For global calls, use Non-global location is required for requests using AutoML models or custom glossaries. Models and glossaries must be within the same region (have same location-id), otherwise an INVALID_ARGUMENT (400) error is returned. |
Request body
The request body contains data with the following structure:
JSON representation |
---|
{ "contents": [ string ], "mimeType": string, "sourceLanguageCode": string, "targetLanguageCode": string, "model": string, "glossaryConfig": { object ( |
Fields | |
---|---|
contents[] |
Required. The content of the input in string format. We recommend the total content be less than 30,000 codepoints. The max length of this field is 1024. Use locations.batchTranslateText for larger text. |
mimeType |
Optional. The format of the source text, for example, "text/html", "text/plain". If left blank, the MIME type defaults to "text/html". |
sourceLanguageCode |
Optional. The ISO-639 language code of the input text if known, for example, "en-US" or "sr-Latn". Supported language codes are listed in Language Support. If the source language isn't specified, the API attempts to identify the source language automatically and returns the source language within the response. |
targetLanguageCode |
Required. The ISO-639 language code to use for translation of the input text, set to one of the language codes listed in Language Support. |
model |
Optional. The The format depends on model type:
For global (non-regionalized) requests, use If not provided, the default Google model (NMT) will be used Authorization requires one or more of the following IAM permissions on the specified resource
|
glossaryConfig |
Optional. Glossary to be applied. The glossary must be within the same region (have the same location-id) as the model, otherwise an INVALID_ARGUMENT (400) error is returned. Authorization requires the following IAM permission on the specified resource
|
transliterationConfig |
Optional. Transliteration to be applied. |
labels |
Optional. The labels with user-defined metadata for the request. Label keys and values can be no longer than 63 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. Label values are optional. Label keys must start with a letter. See https://cloud.google.com/translate/docs/advanced/labels for more information. |
Response body
If successful, the response body contains an instance of TranslateTextResponse
.
Authorization scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/cloud-platform
https://www.googleapis.com/auth/cloud-translation
For more information, see the Authentication Overview.