Modules@robinpath/anthropic
anthropic

@robinpath/anthropic

0.1.2Node.jsPublic

Anthropic module for RobinPath.

Anthropic

Anthropic module for RobinPath.

Package: @robinpath/anthropic | Category: Ai | Type: Integration

Authentication

anthropic.setCredentials "your-credentials"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the anthropic module when you need to:

  • createMessage -- Use anthropic.createMessage to perform this operation
  • chat -- Use anthropic.chat to perform this operation
  • summarize -- Use anthropic.summarize to perform this operation
  • translate -- Use anthropic.translate to perform this operation
  • extract -- Use anthropic.extract to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure anthropic credentials.object
createMessagecreateMessageobject
chatchatobject
summarizesummarizeobject
translatetranslateobject
extractextractobject
classifyclassifyobject
analyzeImageanalyzeImageobject
countTokenscountTokensobject
listModelslistModelsobject
createBatchcreateBatchobject
getBatchgetBatchobject
listBatcheslistBatchesobject
cancelBatchcancelBatchobject
getBatchResultsgetBatchResultsobject
completecompleteobject
generateCodegenerateCodeobject

Functions

setCredentials

Configure anthropic credentials.

Module: anthropic | Returns: object -- API response.

anthropic.setCredentials
ParameterTypeRequiredDescription
apiKeystringYesapiKey

createMessage

createMessage

Module: anthropic | Returns: object -- API response.

anthropic.createMessage
ParameterTypeRequiredDescription
inputstringNoInput parameter

chat

chat

Module: anthropic | Returns: object -- API response.

anthropic.chat
ParameterTypeRequiredDescription
inputstringNoInput parameter

summarize

summarize

Module: anthropic | Returns: object -- API response.

anthropic.summarize
ParameterTypeRequiredDescription
inputstringNoInput parameter

translate

translate

Module: anthropic | Returns: object -- API response.

anthropic.translate
ParameterTypeRequiredDescription
inputstringNoInput parameter

extract

extract

Module: anthropic | Returns: object -- API response.

anthropic.extract
ParameterTypeRequiredDescription
inputstringNoInput parameter

classify

classify

Module: anthropic | Returns: object -- API response.

anthropic.classify
ParameterTypeRequiredDescription
inputstringNoInput parameter

analyzeImage

analyzeImage

Module: anthropic | Returns: object -- API response.

anthropic.analyzeImage
ParameterTypeRequiredDescription
inputstringNoInput parameter

countTokens

countTokens

Module: anthropic | Returns: object -- API response.

anthropic.countTokens
ParameterTypeRequiredDescription
inputstringNoInput parameter

listModels

listModels

Module: anthropic | Returns: object -- API response.

anthropic.listModels
ParameterTypeRequiredDescription
inputstringNoInput parameter

createBatch

createBatch

Module: anthropic | Returns: object -- API response.

anthropic.createBatch
ParameterTypeRequiredDescription
inputstringNoInput parameter

getBatch

getBatch

Module: anthropic | Returns: object -- API response.

anthropic.getBatch
ParameterTypeRequiredDescription
inputstringNoInput parameter

listBatches

listBatches

Module: anthropic | Returns: object -- API response.

anthropic.listBatches
ParameterTypeRequiredDescription
inputstringNoInput parameter

cancelBatch

cancelBatch

Module: anthropic | Returns: object -- API response.

anthropic.cancelBatch
ParameterTypeRequiredDescription
inputstringNoInput parameter

getBatchResults

getBatchResults

Module: anthropic | Returns: object -- API response.

anthropic.getBatchResults
ParameterTypeRequiredDescription
inputstringNoInput parameter

complete

complete

Module: anthropic | Returns: object -- API response.

anthropic.complete
ParameterTypeRequiredDescription
inputstringNoInput parameter

generateCode

generateCode

Module: anthropic | Returns: object -- API response.

anthropic.generateCode
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Anthropic API error (${res.status}): ${t}Check the error message for details
anthropic.setCredentials requires apiKey.Check the error message for details
anthropic.cancelBatch requires an ID.Check the error message for details
anthropic.complete requires an ID.Check the error message for details
Anthropic: "..." not configured. Call anthropic.setCredentials first.Check the error message for details
@desc "Create message and validate result"
do
  set $result as anthropic.createMessage
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate Models

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  anthropic.setCredentials $token
enddo

@desc "List models and iterate results"
do
  set $result as anthropic.listModels
  each $item in $result
    print $item
  end
enddo

2. Create a new item with createMessage

Create a new resource and capture the result.

@desc "Setup authentication"
do
  anthropic.setCredentials $token
enddo

@desc "Create message"
do
  set $result as anthropic.createMessage
  print "Created: " + $result
enddo

3. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  anthropic.setCredentials $token
enddo

@desc "List models and create message"
do
  set $existing as anthropic.listModels
  if $existing == null
    anthropic.createMessage
    print "Item created"
  else
    print "Item already exists"
  end
enddo

4. Multi-step Anthropic workflow

Chain multiple anthropic operations together.

@desc "Setup authentication"
do
  anthropic.setCredentials $token
enddo

@desc "Create message, chat, and more"
do
  set $r_createMessage as anthropic.createMessage
  set $r_chat as anthropic.chat
  set $r_summarize as anthropic.summarize
  print "All operations complete"
enddo

5. Safe createMessage with validation

Check results before proceeding.

@desc "Setup authentication"
do
  anthropic.setCredentials $token
enddo

@desc "Create message and validate result"
do
  set $result as anthropic.createMessage
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • openai -- OpenAI module for complementary functionality
  • ai -- AI module for complementary functionality
  • deepl -- DeepL module for complementary functionality
  • translate -- Translate module for complementary functionality
  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.2latest1 months ago
Install
$ robinpath add @robinpath/anthropic

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.2
LicenseMIT
Unpacked Size4.5 KB
Versions1
Weekly Downloads26
Total Downloads26
Stars0
Last Publish1 months ago
Created1 months ago

Keywords

Category

ai