Client to bundle configuration needed for API requests.
Parameters
target_language(str) – (Optional) The target language used for
translations and language names. (Defaults toENGLISH_ISO_639.)
credentials(Credentials) – (Optional) The OAuth2 Credentials to use for this
client. If not passed (and if no_httpobject is
passed), falls back to the default inferred from the
environment.
_http(Session) – (Optional) HTTP object to make requests. Can be any object
that definesrequest()with the same interface asrequests.Session.request(). If not passed, an_httpobject is created that is bound to thecredentialsfor the current object.
This parameter should be considered private, and could
change in the future.
client_info(ClientInfo) – The client info used to send a user-agent string along with API
requests. IfNone, then default info will be used. Generally,
you only need to set this if you’re developing your own library
or partner tool.
client_options(ClientOptionsordict) – (Optional) Client options used to set user options on the client.
API Endpoint should be set through client_options.
A list of dictionaries for each queried value. Each
dictionary typically contains three keys
confidence: The confidence in language detection, a
float between 0 and 1.
input: The corresponding input value.
language: The detected language (as an ISO 639-1
language code).
though the keyconfidencemay not always be present.
If only a single value is passed, then only a single
dictionary will be returned.
Raises
ValueErrorif the number of
detections is not equal to the number of values.ValueErrorif a value
produces a list of detections with 0 or multiple results
in it.
List of dictionaries. Each dictionary contains a supported
ISO 639-1 language code (using the dictionary keylanguage). Iftarget_languageis passed, each
dictionary will also contain the name of each supported
language (localized to the target language).
target_language(str) – The language to translate results into. This
is required by the API and defaults to
the target language of the current instance.
format(str) – (Optional) One oftextorhtml, to specify
if the input text is plain text or HTML.
source_language(str) – (Optional) The language of the text to
be translated.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [3.21.1 (latest)](/python/docs/reference/translate/latest/client)\n- [3.21.0](/python/docs/reference/translate/3.21.0/client)\n- [3.20.3](/python/docs/reference/translate/3.20.3/client)\n- [3.19.0](/python/docs/reference/translate/3.19.0/client)\n- [3.18.0](/python/docs/reference/translate/3.18.0/client)\n- [3.17.0](/python/docs/reference/translate/3.17.0/client)\n- [3.15.5](/python/docs/reference/translate/3.15.5/client)\n- [3.14.0](/python/docs/reference/translate/3.14.0/client)\n- [3.13.0](/python/docs/reference/translate/3.13.0/client)\n- [3.12.1](/python/docs/reference/translate/3.12.1/client)\n- [3.11.3](/python/docs/reference/translate/3.11.3/client)\n- [3.10.1](/python/docs/reference/translate/3.10.1/client)\n- [3.9.0](/python/docs/reference/translate/3.9.0/client)\n- [3.8.4](/python/docs/reference/translate/3.8.4/client)\n- [3.7.4](/python/docs/reference/translate/3.7.4/client)\n- [3.6.1](/python/docs/reference/translate/3.6.1/client)\n- [3.5.0](/python/docs/reference/translate/3.5.0/client)\n- [3.4.1](/python/docs/reference/translate/3.4.1/client)\n- [3.3.2](/python/docs/reference/translate/3.3.2/client)\n- [3.2.1](/python/docs/reference/translate/3.2.1/client)\n- [3.1.0](/python/docs/reference/translate/3.1.0/client)\n- [3.0.2](/python/docs/reference/translate/3.0.2/client)\n- [2.0.4](/python/docs/reference/translate/2.0.4/client)\n- [1.7.2](/python/docs/reference/translate/1.7.2/client)\n- [1.6.0](/python/docs/reference/translate/1.6.0/client) \n\nTranslation Client\n==================\n\nClient for interacting with the Google Cloud Translation API.\n\n### google.cloud.translate_v2.client.BASE(*= 'base* )\n\nBase translation model.\n\n### *class* google.cloud.translate_v2.client.Client(target_language='en', credentials=None, _http=None, client_info=None, client_options=None)\n\nBases: `google.cloud.client.Client`\n\nClient to bundle configuration needed for API requests.\n\n- **Parameters**\n\n - **target_language** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The target language used for\n translations and language names. (Defaults to\n `ENGLISH_ISO_639`.)\n\n - **credentials** ([`Credentials`](https://googleapis.dev/python/google-auth/latest/reference/google.auth.credentials.html#google.auth.credentials.Credentials)) -- (Optional) The OAuth2 Credentials to use for this\n client. If not passed (and if no `_http` object is\n passed), falls back to the default inferred from the\n environment.\n\n - **_http** (`Session`) -- (Optional) HTTP object to make requests. Can be any object\n that defines `request()` with the same interface as\n `requests.Session.request()`. If not passed, an\n `_http` object is created that is bound to the\n `credentials` for the current object.\n This parameter should be considered private, and could\n change in the future.\n\n - **client_info** ([`ClientInfo`](https://googleapis.dev/python/google-api-core/latest/client_info.html#google.api_core.client_info.ClientInfo)) -- The client info used to send a user-agent string along with API\n requests. If `None`, then default info will be used. Generally,\n you only need to set this if you're developing your own library\n or partner tool.\n\n - **client_options** ([`ClientOptions`](https://googleapis.dev/python/google-api-core/latest/client_options.html#google.api_core.client_options.ClientOptions) or [`dict`](https://docs.python.org/3/library/stdtypes.html#dict)) -- (Optional) Client options used to set user options on the client.\n API Endpoint should be set through client_options.\n\n#### SCOPE(*: Union\\[Tuple\\[[str](https://docs.python.org/3/library/stdtypes.html#str), ...\\], [None](https://docs.python.org/3/library/constants.html#None)* *= ('\u003chttps://www.googleapis.com/auth/cloud-platform\u003e',* )\n\nThe scopes required for authenticating.\n\n#### detect_language(values)\n\nDetect the language of a string or list of strings.\n\nSee \u003chttps://cloud.google.com/translate/docs/detecting-language\u003e\n\n- **Parameters**\n\n **values** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* list\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#list\u003e)) -- String or list of strings that will have\n language detected.\n- **Return type**\n\n [dict](https://docs.python.org/3/library/stdtypes.html#dict) or [list](https://docs.python.org/3/library/stdtypes.html#list)\n- **Returns**\n\n A list of dictionaries for each queried value. Each\n dictionary typically contains three keys\n - `confidence`: The confidence in language detection, a\n float between 0 and 1.\n\n - `input`: The corresponding input value.\n\n - `language`: The detected language (as an ISO 639-1\n language code).\n\n though the key `confidence` may not always be present.\n\n If only a single value is passed, then only a single\n dictionary will be returned.\n- **Raises**\n\n `ValueError` if the number of\n detections is not equal to the number of values.\n `ValueError` if a value\n produces a list of detections with 0 or multiple results\n in it.\n\n#### get_languages(target_language=None)\n\nGet list of supported languages for translation.\n\nResponse\n\nSee\n\u003chttps://cloud.google.com/translate/docs/discovering-supported-languages\u003e\n\n- **Parameters**\n\n **target_language** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The language used to localize\n returned language names. Defaults to the\n target language on the current client.\n- **Return type**\n\n [list](https://docs.python.org/3/library/stdtypes.html#list)\n- **Returns**\n\n List of dictionaries. Each dictionary contains a supported\n ISO 639-1 language code (using the dictionary key\n `language`). If `target_language` is passed, each\n dictionary will also contain the name of each supported\n language (localized to the target language).\n\n#### translate(values, target_language=None, format_=None, source_language=None, customization_ids=(), model=None)\n\nTranslate a string or list of strings.\n\nSee \u003chttps://cloud.google.com/translate/docs/translating-text\u003e\n\n- **Parameters**\n\n - **values** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* list\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#list\u003e)) -- String or list of strings to translate.\n\n - **target_language** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- The language to translate results into. This\n is required by the API and defaults to\n the target language of the current instance.\n\n - **format** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) One of `text` or `html`, to specify\n if the input text is plain text or HTML.\n\n - **source_language** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The language of the text to\n be translated.\n\n - **customization_ids** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)\\* or *\\[* list\\*\\](\u003chttps://docs.python.org/3/library/stdtypes.html#list\u003e)) -- (Optional) ID or list of customization IDs\n for translation. Sets the `cid` parameter\n in the query.\n\n - **model** ([*str*](https://docs.python.org/3/library/stdtypes.html#str)) -- (Optional) The model used to translate the text, such\n as `'base'` or `'nmt'`.\n\n- **Return type**\n\n [dict](https://docs.python.org/3/library/stdtypes.html#dict) or [list](https://docs.python.org/3/library/stdtypes.html#list)\n- **Returns**\n\n A list of dictionaries for each queried value. Each\n dictionary typically contains three keys (though not\n all will be present in all cases)\n - `detectedSourceLanguage`: The detected language (as an\n ISO 639-1 language code) of the text.\n\n - `translatedText`: The translation of the text into the\n target language.\n\n - `input`: The corresponding input value.\n\n - `model`: The model used to translate the text.\n\n If only a single value is passed, then only a single\n dictionary will be returned.\n- **Raises**\n\n `ValueError` if the number of\n values and translations differ.\n\n### google.cloud.translate_v2.client.ENGLISH_ISO_639(*= 'en* )\n\nISO 639-1 language code for English.\n\n### google.cloud.translate_v2.client.NMT(*= 'nmt* )\n\nNeural Machine Translation model."]]