Guia de início rápido: como usar bibliotecas de cliente
Esta página mostra como começar a usar a API Food Ordering AI Agent na sua linguagem de programação favorita.
Antes de começar
- Faça login na sua Google Cloud conta. Se você começou a usar o Google Cloudagora, crie uma conta para avaliar o desempenho dos nossos produtos em situações reais. Clientes novos também recebem US $300 em créditos para executar, testar e implantar cargas de trabalho.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Food Ordering AI Agent API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Food Ordering AI Agent API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Create a service account:
-
Ensure that you have the Create Service Accounts IAM role
(
roles/iam.serviceAccountCreator) and the Project IAM Admin role (roles/resourcemanager.projectIamAdmin). Learn how to grant roles. -
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart. - Click Create and continue.
-
Grant the Project > Owner role to the service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
Ensure that you have the Create Service Accounts IAM role
(
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALSto the path of the JSON file that contains your credentials. This variable applies only to your current shell session, so if you open a new session, set the variable again.
Instale a biblioteca de cliente
C#
Para mais informações sobre a configuração do ambiente de desenvolvimento do C#, consulte o Guia de configuração do ambiente de desenvolvimento do C#.
Install-Package Google.Cloud.PubSub.V1 -Pre
Go
go get cloud.google.com/go/pubsub
Java
Para mais informações sobre a configuração do ambiente de desenvolvimento do Java, consulte o Guia de configuração do ambiente de desenvolvimento do Java.
Se você estiver usando Maven, adicione
o código abaixo ao arquivo pom.xml. Para mais informações sobre
BOMs, consulte BOM das bibliotecas do Google Cloud Platform.
Se você estiver usando Gradle, adicione isto às dependências:
Se você estiver usando sbt, adicione o seguinte às suas dependências:
Se você estiver usando o Visual Studio Code ou o IntelliJ, poderá adicionar bibliotecas de cliente ao projeto usando estes plug-ins de ambiente de desenvolvimento integrado:
Os plug-ins também oferecem outras funcionalidades, como gerenciamento de chaves de contas de serviço. Consulte a documentação de cada plug-in para mais detalhes.
Node.js
Para mais informações sobre a configuração do ambiente de desenvolvimento do Node.js, consulte o Guia de configuração do ambiente de desenvolvimento do Node.js.
npm install @google-cloud/pubsub
PHP
composer require google/cloud-pubsub
Python
Para mais informações sobre a configuração do ambiente de desenvolvimento do Python, consulte o Guia de configuração do ambiente de desenvolvimento do Python.
pip install --upgrade google-cloud-pubsub
Ruby
Para mais informações sobre a configuração do ambiente de desenvolvimento do Ruby, consulte o Guia de configuração do ambiente de desenvolvimento Ruby.
gem install google-cloud-pubsub
Fazer algo
Agora você pode usar o agente de IA de Pedido de comida para fazer algo. Execute o código a seguir para realizar a primeira coisa:
C#
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Go
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Java
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Node.js
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
PHP
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Python
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Ruby
Para autenticar no Food Ordering AI Agent, configure o Application Default Credentials. Se quiser mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.
Como foi?
Limpar
Para evitar cobranças na sua Conta do Google pelos recursos usados neste guia de início rápido:
- Use o Google Cloud console para excluir o projeto, se você não precisar mais dele.
A seguir
Saiba mais sobre as bibliotecas de cliente da API do Agente de IA de Pedido de comida.