Action

Claude: Direct Request

Posted by agiletortoise, Last update about 1 month ago

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

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

For more information and examples incorporating Antropic Claude, visit the integration guide

Steps

  • script

    // create GoogleAI object
    let ai = new AnthropicAI()
    const model = "claude-3-haiku-20240307"
    
    // make API request
    let response = ai.request({
    	"path": "/messages",
    	"method": "POST",
    	"data": {
    		"model": model,
    		"max_tokens": 1024,
    		"messages": [
    			{
    				"content": "What is your name?",
    				"role": "user"
    			}
    		]
    	}
    })
    
    // 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.