Skip to main content

Anthropic

Overview

This connector provides a connection to Anthropic.

It is a wrapper around the standard Anthropic Python library.

Requirements

Before creating the connector, you will need the following information available for the Anthropic connection.

  • API key

Creating

To add an instance of the Anthropic connector, you can use the Web UI or the CLI.

$ sand connectors create anthropic --name myLLM \
--api-key="sk-ant-..."
✅ Connector created successfully!
Connector ID: cnc-5ab0075c465c8321

Usage

To use this module, you first must initialize the connector in a step:

anthro = sandgarden.connectors['myLLM']

Then call the API just as you would the Anthropic Python library:

def answer_question(anthro, context):
res = anthro.messages.create(
model="claude-3-5-sonnet-latest",
max_tokens=1024,
messages=[
{"role": "user", "content": context}
])

return res.content[0].text