Appearance
Anthropic
Use Claude models via the direct Anthropic API (AnthropicModel) or the Anthropic Bedrock SDK (AnthropicBedrockModel on AWS).
Option 1: Anthropic via AWS Bedrock SDK
Use Claude through AWS with the Anthropic Bedrock SDK — best when you already run on AWS and want IAM-based access.
For standalone invoke / stream usage, see LLM Models — Anthropic via Bedrock SDK.
Install
bash
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.3.1
pip install --extra-index-url https://core-packages.elsai.ai/root/ "elsai-model[anthropic-bedrock]==2.1.0"Setup
- Enable Claude model access in the Bedrock console.
- Configure AWS credentials and export the model ID:
bash
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=us-west-2
export ANTHROPIC_BEDROCK_MODEL_ID=global.anthropic.claude-sonnet-4-6Agent — basic
python
import os
from elsai import Agent
from elsai_model import LLM, Provider
model = LLM(
provider=Provider.ANTHROPIC_BEDROCK,
model=os.getenv("ANTHROPIC_BEDROCK_MODEL_ID", "global.anthropic.claude-sonnet-4-6"),
region_name=os.getenv("AWS_DEFAULT_REGION", os.getenv("AWS_REGION", "us-west-2")),
max_tokens=256,
temperature=0.2,
)
agent = Agent(
model=model,
system_prompt="You are a concise assistant.",
)
result = agent("Explain the theory of relativity simply.")
print(result)Option 2: Anthropic direct API
Call Claude directly with an Anthropic API key — no AWS required.
For standalone invoke / stream usage, see LLM Models — Anthropic (direct API).
Install
bash
pip install --extra-index-url https://elsai-agents.elsai.ai/root/ elsai-agents==0.3.1
pip install --extra-index-url https://core-packages.elsai.ai/root/ "elsai-model[anthropic]==2.1.0"Setup
- Create an Anthropic API key.
- Export credentials:
bash
export ANTHROPIC_API_KEY=sk-ant-...
export ANTHROPIC_MODEL_NAME=claude-3-5-sonnet-latestAgent — basic
python
import os
from elsai import Agent
from elsai_model import LLM, Provider
model = LLM(
provider=Provider.ANTHROPIC,
model=os.getenv("ANTHROPIC_MODEL_NAME", "claude-3-5-sonnet-latest"),
api_key=os.environ["ANTHROPIC_API_KEY"],
max_tokens=256,
params={"temperature": 0.2},
)
agent = Agent(
model=model,
system_prompt="You are a concise assistant.",
)
result = agent("Explain the theory of relativity simply.")
print(result)