Action

OpenAI: Direct OpenAI Request

Posted by agiletortoise, Last update over 1 year ago

Shows making a call with the OpenAI.request function to access all options of the API. This is meant only as an example action for people interested in building advanced OpenAI/Chat actions.

For more information on using this action, visit our OpenAI integration guide

Steps

  • script

    // create OpenAI object
    let ai = new OpenAI()
    
    // make API request
    let response = ai.request({
    	"path": "/chat/completions",
    	"method": "POST",
    	"data": {
    		"model": "gpt-3.5-turbo",
    		"messages": [
    			{
    				"role": "user",
    				"content": "What is your name?"
    			}
    		]
    	}
    })
    
    // 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.