Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Endpoints globais e multirregionais
O Cloud Translation Advanced oferece um endpoint global, além de
endpoints multirregionais da UE e dos EUA:
translate.googleapis.com (global)
translate-eu.googleapis.com
translate-us.googleapis.com
Se você usar um endpoint multirregional, o processamento de dados em repouso
e de machine learning permanecerá dentro dos limites europeus da UE ou dos EUA. Esses
endpoints multirregionais são importantes se a localização dos dados precisar ser
controlada para obedecer aos requisitos regulamentares locais.
Se você não especificar um endpoint, o Cloud Translation Advanced usará o endpoint
global por padrão.
Endpoints globais x multirregionais
Há diferenças de uso entre o endpoint multirregional
e o endpoint global:
As traduções de texto que usam modelos personalizados do AutoML não são compatíveis.
É possível usar apenas o modelo NMT pré-treinado.
Os recursos que não estão no GA (ainda na Visualização) não são compatíveis.
As chamadas pelo endpoint global não podem acessar recursos criados
usando um endpoint multirregional. Da mesma forma, as chamadas pelo endpoint
multirregional não podem acessar recursos criados usando o endpoint
global.
Como restringir locais dos recursos
Os administradores de políticas da organização podem restringir as regiões disponíveis para
os recursos da edição Advanced do Cloud Translation criando uma restrição de locais
de recursos. Se
ela for definida, os usuários do Cloud Translation Advanced poderão criar recursos somente em um
local específico.
Especificar um endpoint
O exemplo a seguir mostra uma tradução de texto que usa um endpoint
multirregional. Se você usar as bibliotecas de cliente, defina o endpoint da API como parte das opções
do cliente. Para alguns exemplos, consulte Como configurar o local usando bibliotecas
de cliente
no guia da API Cloud Natural Language.
REST
Antes de usar os dados da solicitação abaixo, faça as substituições a seguir:
PROJECT_NUMBER_OR_ID: o ID numérico ou alfanumérico do projeto do Google Cloud
ENDPOINT: endpoint regional, que determina onde seus dados
residem. Por exemplo, translate-eu.googleapis.com.
LOCATION: região em que você quer executar a operação. Escolha
uma região dentro do limite continental do endpoint regional. Por
exemplo, se você usar o endpoint translate-eu.googleapis.com,
especifique uma região na Europa, como europe-west1.
Método HTTP e URL:
POST https://ENDPOINT/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateText
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-02-01 UTC."],[],[],null,["# Global and multi-regional endpoints\n===================================\n\nCloud Translation - Advanced offers a global endpoint as well as EU and US\nmulti-regional endpoints:\n\n- `translate.googleapis.com` (global)\n- `translate-eu.googleapis.com`\n- `translate-us.googleapis.com`\n\nIf you use a multi-regional endpoint, your data at-rest and machine learning\nprocessing stays within the continental boundaries of the EU or US. These\nmulti-regional endpoints are important if your data's location must be\ncontrolled to comply with local regulatory requirements.\n\nIf you don't specify an endpoint, Cloud Translation - Advanced uses the global\nendpoint by default.\n\nGlobal versus multi-regional endpoints\n--------------------------------------\n\nWhen using a multi-regional endpoint, there are some difference when compared to\nusing the global endpoint:\n\n- Text translations that use custom AutoML models are not supported. You can use only the pre-trained NMT model.\n- Features that are not GA (still in [Preview](/products#product-launch-stages)) are not supported.\n- Calls through the global endpoint cannot access resources that were created by using a multi-regional endpoint. Similarly, calls through a multi-regional endpoint cannot access resources that were created by using the global endpoint.\n\nRestricting resource locations\n------------------------------\n\nOrganization policy administrators can restrict the regions available for\nCloud Translation - Advanced resources by [creating a resource locations\nconstraint](/resource-manager/docs/organization-policy/defining-locations). If\nset, Cloud Translation - Advanced users would be able to create resources only in a\nparticular location.\n\nRestricting global API endpoint usage\n-------------------------------------\n\nTo help enforce the use of regional endpoints, organization policy\nadministrators can use the `constraints/gcp.restrictEndpointUsage` organization\npolicy constraint to block requests to the global API endpoint. For more\ninformation, see [Restricting endpoint\nusage](/assured-workloads/docs/restrict-endpoint-usage).\n\nSpecify an endpoint\n-------------------\n\nThe following example shows a text translation that uses a multi-regional\nendpoint. If you use the client libraries, set the API endpoint as part of the\nclient options. For some examples, see [Setting the location using client\nlibraries](/natural-language/docs/locations#setting_the_location_using_client_libraries)\nin the Cloud Natural Language API guide. \n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_NUMBER_OR_ID\u003c/var\u003e: the numeric or alphanumeric ID of your Google Cloud project\n- \u003cvar translate=\"no\"\u003eENDPOINT\u003c/var\u003e: Regional endpoint, which determines where your data resides. For example, `translate-eu.googleapis.com`.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: Region where you want to run this operation. You must pick a region inside the continental boundary of the regional endpoint. For example, if you use the `translate-eu.googleapis.com` endpoint, specify a region in Europe such as `europe-west1`.\n\n\nHTTP method and URL:\n\n```\nPOST https://ENDPOINT/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateText\n```\n\n\nRequest JSON body:\n\n```\n{\n \"model\": \"projects/PROJECT_NUMBER_OR_ID/locations/LOCATION/models/general/base\",\n \"sourceLanguageCode\": \"en\",\n \"targetLanguageCode\": \"de\",\n \"contents\": [\"Come here!\"]\n}\n```\n\nTo send your request, choose one of these options: \n\n#### curl\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"x-goog-user-project: PROJECT_NUMBER_OR_ID\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://ENDPOINT/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateText\"\n```\n\n#### PowerShell\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\"; \"x-goog-user-project\" = \"PROJECT_NUMBER_OR_ID\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://ENDPOINT/v3/projects/PROJECT_NUMBER_OR_ID/locations/LOCATION:translateText\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"translations\": [\n {\n \"translatedText\": \"Komm her!\",\n \"model\": \"projects/PROJECT_NUMBER_OR_ID/locations/LOCATION/models/general/base\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e"]]