Action

Gemini: Direct Request

Posted by agiletortoise, Last update 8 months ago

This action demonstrates making a call with the Google Gemini generateContent endpoint to access all API options. It is meant only as an example action for people interested in building advanced Gemini actions.

The results of the call are logged in the action log.

For more information and examples incorporating Google Gemini, visit the integration guide

Steps

  • script

    // create GoogleAI object
    let ai = new GoogleAI()
    
    // make API request
    let response = ai.request({
    	"path": "/generateContent",
    	"method": "POST",
    	"model": "models/gemini-1.0-pro",
    	"data": {
    		"contents": [
    			{
    				"parts": {
    					"text": "What is your name?"
    				},
    				"role": "user"
    			}
    		],
    		"safetySettings": {
    			"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
            "threshold": "BLOCK_MEDIUM_AND_ABOVE"
    		}
    	}
    })
    
    // report status
    console.log(`CODE: ${response.statusCode}
    
    ERR: ${response.error}
    
    ${response.responseText}
    `)

Options

  • After Success Default
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.