Anthropic
datapizza.clients.anthropic.AnthropicClient
Bases: Client
A client for interacting with the Anthropic API (Claude).
This class provides methods for invoking the Anthropic API to generate responses based on given input data. It extends the Client class.
__init__
__init__(
api_key,
model="claude-3-5-sonnet-latest",
system_prompt="",
temperature=None,
cache=None,
)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key
|
str
|
The API key for the Anthropic API. |
required |
model
|
str
|
The model to use for the Anthropic API. |
'claude-3-5-sonnet-latest'
|
system_prompt
|
str
|
The system prompt to use for the Anthropic API. |
''
|
temperature
|
float | None
|
The temperature to use for the Anthropic API. |
None
|
cache
|
Cache | None
|
The cache to use for the Anthropic API. |
None
|
Usage example
from datapizza.clients.anthropic import AnthropicClient
client = AnthropicClient(
api_key="YOUR_API_KEY"
model="claude-3-5-sonnet-20240620",
)
resposne = client.invoke("hi")
print(response.text)
Show thinking
import os
from datapizza.clients.anthropic import AnthropicClient
from dotenv import load_dotenv
load_dotenv()
client = AnthropicClient(
api_key=os.getenv("ANTHROPIC_API_KEY"),
model="claude-sonnet-4-0",
)
response = client.invoke("Hi", thinking = {"type": "enabled", "budget_tokens": 1024})
print(response)