Anthropic
Terminal
pip install "assertllm[anthropic]"
export ANTHROPIC_API_KEY=sk-ant-...Usage
test_anthropic.py
from assertllm import expect, llm_test
@llm_test(
expect.is_not_empty(),
expect.contains("4"),
provider="anthropic",
model="claude-sonnet-4-6",
)
def test_anthropic(llm):
llm("What is 2+2?")Output
test_anthropic.py::test_anthropic
"2 + 2 equals 4."
✓ is_not_empty()
✓ contains("4")
PASSED [0.5s]Supported Models
| Model | ID |
|---|---|
| Claude Sonnet 4 | claude-sonnet-4-20250514 |
| Claude Haiku 4.5 | claude-haiku-4-5-20251001 |
Per-call Model Override
test_override.py
@llm_test(
expect.is_not_empty(),
provider="anthropic",
model="claude-sonnet-4-6",
)
def test_override(llm):
llm("Quick answer: 2+2?", model="claude-haiku-4-5-20251001")Last updated on