Quickstart: Setup the Natural Language API

This guide provides all required setup steps to start using Natural Language.

About the Google Cloud console

The Google Cloud console, is a web UI used to provision, configure, manage, and monitor systems that use Google Cloud products. You use the Google Cloud console to set up and manage Natural Language resources.

Create a project

To use services provided by Google Cloud, you must create a project.

A project organizes all your Google Cloud resources. A project consists of the following components:

  • a set of collaborators
  • enabled APIs (and other resources)
  • monitoring tools
  • billing information
  • authentication and access controls

You can create one project, or you can create multiple projects and use them to organize your Google Cloud resources in a resource hierarchy. For more information on projects, see the Resource Manager documentation.

In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

Go to project selector

Enable billing

A billing account is used to define who pays for a given set of resources, and it can be linked to one or more projects. Project usage is charged to the linked billing account. In most cases, you configure billing when you create a project. For more information, see the Billing documentation.

Make sure that billing is enabled for your Google Cloud project.

Enable the API

You must enable the Cloud Natural Language API for your project. For more information on enabling APIs, see the Service Usage documentation.

Enable the Cloud Natural Language API.

Enable the API

Install and initialize the gcloud CLI

If you plan to use the Natural Language API, you need to install and initialize the gcloud CLI. gcloud CLI is a set of tools that you can use to manage resources and applications hosted on Google Cloud. This includes the gcloud CLI. The following link provides instructions:

Install the Google Cloud CLI, then initialize it by running the following command:

gcloud init

Set up authentication

Any client application that uses the API must be authenticated and granted access to the requested resources. How you set up authentication depends on whether you are working in a local development environment or setting up a production environment. For more information, see Set up Application Default Credentials.

Select the tabs for how you plan to access the API:

gcloud

Install the Google Cloud CLI, then initialize it by running the following command:

gcloud init

C#

To use the .NET samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

Go

To use the Go samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

Java

To use the Java samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

Node.js

To use the Node.js samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

PHP

To use the PHP samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

Python

To use the Python samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

Ruby

To use the Ruby samples on this page from a local development environment, install and initialize the gcloud CLI, and then set up Application Default Credentials with your user credentials.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. Create local authentication credentials for your Google Account:

    gcloud auth application-default login

For more information, see Set up authentication for a local development environment in the Google Cloud authentication documentation.

REST

To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.

    Install the Google Cloud CLI, then initialize it by running the following command:

    gcloud init

For information about setting up authentication for a production environment, see Set up Application Default Credentials for code running on Google Cloud in the Google Cloud authentication documentation.

Install the Natural Language API client library

You have three options for calling the Natural Language API:

The client libraries are available for several popular languages. For information on installing the client libraries, see Cloud Natural Language Client Libraries.

About roles

No role is required to access the Cloud Natural Language API. Authenticated users or applications can make calls to the API, regardless of their permissions.