Learn R Programming

gemini.R (version 0.17.2)

gemini_request: Send POST request to Gemini API

Description

Sends a POST request to the Gemini API with the specified URL and body, and returns the response as a character string.

Usage

gemini_request(url, body)

Value

Character string containing the API response.

Arguments

url

Character. The Gemini API endpoint URL.

body

List. The request body to send as JSON.

Examples

Run this code
if (FALSE) {
body <- list(contents = list(list(parts = list(list(text = "Hello!")))))
gemini_request(
  paste0("https://generativelanguage.googleapis.com/v1beta/models/",
     "gemini-2.5-flash-image-preview:generateContent"), body)
}

Run the code above in your browser using DataLab