PaLMr - Interface for 'Google Pathways Language Model 2 (PaLM 2)'

CRAN Version download count

As Google Gemini is on its way, PaLM becomes legacy. We recommend that you use the latest R package, GenAI: Generative Artificial Intelligence. This package allows you to seamlessly utilize both ChatGPT from OpenAI and Gemini Pro from Google!

Basic Information

PaLMr: Interface for 'Google Pathways Language Model 2 (PaLM 2)

'Google Pathways Language Model 2 (PaLM 2)' as a coding and writing assistant designed for 'R'. With a range of functions, including natural language processing and coding optimization, to assist 'R' developers in simplifying tedious coding tasks and content searching.

Imports: httr, jsonlite

Author: Li Yuan

Maintainer: Li Yuan <>


License: CC BY 4.0


Needs Compilation: no

CRAN checks: PaLMr results


  1. Prior to utilizing the PaLMr package, several prerequisites must be met.

    1. Ensure that you possess an eligible device equipped with R.

    2. Access to the internet is essential to generate text or engage in chat through PaLMr.

    3. Obtain an API key from Google. To acquire an API key for Google's models, refer to: Get an API key

  2. Installation (2 options)

    1. Install the package from The Comprehensive R Archive Network (CRAN).


    2. Install the package from PaLMr official website.

      install.packages("", repos=NULL, method="libcurl")

  3. Setup and get your first AI generated response using PaLMr

    Open In Colab
    # Install the library
    # Import the library
    # Connect to the PaLM 2 text model, replace API_KEY with your api key
    palm.model = palm.connect("v1beta3",
    prompt = "Write a story about a magic backpack."
    generated.text = palm.txt(palm.model,
  4. See the documentation for more functions.

API Proxy Service

See more detail about this service.

For individuals utilizing Generative AI service providers with API usage location restrictions in certain countries/regions, this service is tailored for those who possess a valid API key but find themselves outside their home countries/regions due to travel, work, or study in regions not covered by some Generative AI service providers.

How to use this service in PaLMr? Set TRUE to parameter proxy in function palm.connect and use the returned model parameter for text generations.