• AIPressRoom
  • Posts
  • The way to Use Google’s PaLM 2 API with Python | by Elise Landman | Aug, 2023

The way to Use Google’s PaLM 2 API with Python | by Elise Landman | Aug, 2023

Generative AI is all over. We see an increasing number of firms investing on this highly effective know-how because it turns into more and more clear how a lot potential it has. And as Gartner states: within the close to future, [Generative AI] will change into a aggressive benefit and differentiator.

“within the close to future, [Generative AI] will change into a aggressive benefit and differentiator.”

Sadly, growing Generative AI fashions shouldn’t be solely a posh work of engineering, however it’s often fairly an expensive challenge. Fortunately, we would not have to develop these ourselves — we will reuse what has been pre-developed for us: with APIs! Subsequently, let’s not wait any longer — let’s leap proper into how we will leverage Generative AI by integrating it into our utility.

For this text, we’ll be taking a look at Google’s reply to LLMs: the PaLM 2 API. PaLM 2 is Google’s latest model of their Pathways Language Mannequin, a big language mannequin which makes use of round 5 instances extra coaching information than their preliminary mannequin launched in 2022.

On this article I shall be going by means of some code examples and displaying you methods to authenticate to Google Cloud and use, in addition to customise the PaLM 2 APIs with Python 3.11.

The PaLM 2 APIs might be accessed by means of Google Cloud’s Vertex AI platform. Subsequently, earlier than we will make any API calls, we might want to arrange our Google Cloud account. You’ll be able to sign up here and get $300 in free credits to begin taking part in round with the companies.

As quickly as your account and challenge are arrange, we will go forward and create a service account which we’ll use to authenticate to the Vertex AI APIs. We use service accounts, as a result of we will guarantee entry management to our Google Cloud assets by giving them solely particular IAM permissions. For our use case, we’ll give the service account the Vertex AI Consumer function. This is perhaps too broad in your use case, so I like to recommend checking the available access roles and select which one suits your wants.