@robinpath/anthropic
0.1.2Node.jsPublicAnthropic 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.createMessageto perform this operation - chat -- Use
anthropic.chatto perform this operation - summarize -- Use
anthropic.summarizeto perform this operation - translate -- Use
anthropic.translateto perform this operation - extract -- Use
anthropic.extractto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure anthropic credentials. | object |
createMessage | createMessage | object |
chat | chat | object |
summarize | summarize | object |
translate | translate | object |
extract | extract | object |
classify | classify | object |
analyzeImage | analyzeImage | object |
countTokens | countTokens | object |
listModels | listModels | object |
createBatch | createBatch | object |
getBatch | getBatch | object |
listBatches | listBatches | object |
cancelBatch | cancelBatch | object |
getBatchResults | getBatchResults | object |
complete | complete | object |
generateCode | generateCode | object |
Functions
setCredentials
Configure anthropic credentials.
Module: anthropic | Returns: object -- API response.
anthropic.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
apiKey | string | Yes | apiKey |
createMessage
createMessage
Module: anthropic | Returns: object -- API response.
anthropic.createMessage
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
chat
chat
Module: anthropic | Returns: object -- API response.
anthropic.chat
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
summarize
summarize
Module: anthropic | Returns: object -- API response.
anthropic.summarize
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
translate
translate
Module: anthropic | Returns: object -- API response.
anthropic.translate
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
extract
extract
Module: anthropic | Returns: object -- API response.
anthropic.extract
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
classify
classify
Module: anthropic | Returns: object -- API response.
anthropic.classify
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
analyzeImage
analyzeImage
Module: anthropic | Returns: object -- API response.
anthropic.analyzeImage
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
countTokens
countTokens
Module: anthropic | Returns: object -- API response.
anthropic.countTokens
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listModels
listModels
Module: anthropic | Returns: object -- API response.
anthropic.listModels
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createBatch
createBatch
Module: anthropic | Returns: object -- API response.
anthropic.createBatch
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getBatch
getBatch
Module: anthropic | Returns: object -- API response.
anthropic.getBatch
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listBatches
listBatches
Module: anthropic | Returns: object -- API response.
anthropic.listBatches
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
cancelBatch
cancelBatch
Module: anthropic | Returns: object -- API response.
anthropic.cancelBatch
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getBatchResults
getBatchResults
Module: anthropic | Returns: object -- API response.
anthropic.getBatchResults
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
complete
complete
Module: anthropic | Returns: object -- API response.
anthropic.complete
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
generateCode
generateCode
Module: anthropic | Returns: object -- API response.
anthropic.generateCode
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
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)
| Version | Tag | Published |
|---|---|---|
| 0.1.2 | latest | 1 months ago |
$ robinpath add @robinpath/anthropic
