Skip to content

Commit 00933a5

Browse files
authored
Merge pull request #6 from rlatntjr/main
models - anthropic
2 parents 9259941 + 9064b71 commit 00933a5

File tree

5 files changed

+71
-1
lines changed

5 files changed

+71
-1
lines changed

docs/api-reference/models.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
::: strands.models.bedrock
66
options:
77
heading_level: 2
8+
::: strands.models.anthropic
9+
options:
10+
heading_level: 2
811
::: strands.models.litellm
912
options:
1013
heading_level: 2
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Anthropic
2+
3+
[Anthropic](https://docs.anthropic.com/en/home) is an AI safety and research company focused on building reliable, interpretable, and steerable AI systems. Included in their offerings is the Claude AI family of models, which are known for their conversational abilities, careful reasoning, and capacity to follow complex instructions. The Strands Agents SDK implements an Anthropic provider, allowing users to run agents against Claude models directly.
4+
5+
## Installation
6+
7+
Anthropic is configured as an optional dependency in Strands. To install, run:
8+
9+
```bash
10+
pip install strands-agents[anthropic]
11+
```
12+
13+
## Usage
14+
15+
After installing `anthropic`, you can import and initialize Strands' Anthropic provider as follows:
16+
17+
```python
18+
from strands import Agent
19+
from strands.models.anthropic import AnthropicModel
20+
from strands_tools import calculator
21+
22+
model = AnthropicModel(
23+
client_args={
24+
"api_key": "<KEY>",
25+
},
26+
# **model_config
27+
max_tokens=1028,
28+
model_id="claude-3-7-sonnet-20250219",
29+
params={
30+
"temperature": 0.7,
31+
}
32+
)
33+
34+
agent = Agent(model=model, tools=[calculator])
35+
response = agent("What is 2+2")
36+
print(response)
37+
```
38+
39+
## Configuration
40+
41+
### Client Configuration
42+
43+
The `client_args` configure the underlying Anthropic client. For a complete list of available arguments, please refer to the Anthropic [docs](https://docs.anthropic.com/en/api/client-sdks).
44+
45+
### Model Configuration
46+
47+
The `model_config` configures the underlying model selected for inference. The supported configurations are:
48+
49+
| Parameter | Description | Example | Options |
50+
|------------|-------------|---------|---------|
51+
| `max_tokens` | Maximum number of tokens to generate before stopping | `1028` | [reference](https://docs.anthropic.com/en/api/messages#body-max-tokens)
52+
| `model_id` | ID of a model to use | `claude-3-7-sonnet-20250219` | [reference](https://docs.anthropic.com/en/api/messages#body-model)
53+
| `params` | Model specific parameters | `{"max_tokens": 1000, "temperature": 0.7}` | [reference](https://docs.anthropic.com/en/api/messages)
54+
55+
## Troubleshooting
56+
57+
### Module Not Found
58+
59+
If you encounter the error `ModuleNotFoundError: No module named 'anthropic'`, this means you haven't installed the `anthropic` dependency in your environment. To fix, run `pip install strands-agents[anthropic]`.
60+
61+
## References
62+
63+
- [API](../../../api-reference/models.md)
64+
- [Anthropic](https://docs.anthropic.com/en/home)
65+

docs/user-guide/concepts/model-providers/custom_model_provider.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Strands Agents uses an abstract `Model` class that defines the standard interfac
99
```mermaid
1010
flowchart TD
1111
Base["Model (Base)"] --> Bedrock["Bedrock Model Provider"]
12+
Base --> Anthropic["Anthropic Model Provider"]
1213
Base --> LiteLLM["LiteLLM Model Provider"]
1314
Base --> Ollama["Ollama Model Provider"]
1415
Base --> Custom["Custom Model Provider"]

docs/user-guide/observability-evaluation/traces.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export OTEL_EXPORTER_OTLP_HEADERS="key1=value1,key2=value2"
100100

101101
```python
102102
from strands import Agent
103-
from strands.sdk.telemetry.tracer import get_tracer
103+
from strands.telemetry.tracer import get_tracer
104104

105105
# Configure the tracer
106106
tracer = get_tracer(

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ nav:
7373
- Example Tools Package: user-guide/concepts/tools/example-tools-package.md
7474
- Model Providers:
7575
- Amazon Bedrock: user-guide/concepts/model-providers/amazon-bedrock.md
76+
- Anthropic: user-guide/concepts/model-providers/anthropic.md
7677
- LiteLLM: user-guide/concepts/model-providers/litellm.md
7778
- Ollama: user-guide/concepts/model-providers/ollama.md
7879
- Custom Providers: user-guide/concepts/model-providers/custom_model_provider.md

0 commit comments

Comments
 (0)