Skip to content

Commit 18a8082

Browse files
docs(closes OPEN-8401): strands Agents integration
1 parent 2c54796 commit 18a8082

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "2722b419",
6+
"metadata": {},
7+
"source": [
8+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/openlayer-ai/openlayer-python/blob/main/examples/tracing/strands-agents/strands_agents_tracing.ipynb)\n",
9+
"\n",
10+
"\n",
11+
"# <a id=\"top\">Strands Agents quickstart</a>\n",
12+
"\n",
13+
"This notebook shows how to export traces captured by [Strands Agents](https://strandsagents.com/latest/) to Openlayer. The integration is done via the Openlayer's [OpenTelemetry endpoint](https://www.openlayer.com/docs/integrations/opentelemetry)."
14+
]
15+
},
16+
{
17+
"cell_type": "code",
18+
"execution_count": null,
19+
"id": "0156bc8f",
20+
"metadata": {},
21+
"outputs": [],
22+
"source": [
23+
"!pip install 'strands-agents[otel]'"
24+
]
25+
},
26+
{
27+
"cell_type": "markdown",
28+
"id": "75c2a473",
29+
"metadata": {},
30+
"source": [
31+
"## 1. Set the environment variables"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": null,
37+
"id": "f3f4fa13",
38+
"metadata": {},
39+
"outputs": [],
40+
"source": [
41+
"import os\n",
42+
"\n",
43+
"# Env variables pointing to Openlayer's OpenTelemetry endpoint\n",
44+
"os.environ[\"OTEL_EXPORTER_OTLP_ENDPOINT\"] = \"https://api.openlayer.com/v1/otel\"\n",
45+
"os.environ[\"OTEL_EXPORTER_OTLP_HEADERS\"] = \"Authorization=Bearer YOUR_OPENLAYER_API_KEY_HERE, x-bt-parent=pipeline_id:YOUR_PIPELINE_ID_HERE\"\n",
46+
"\n",
47+
"# AWS credentials for Strands Agents – other authentication methods are available as well\n",
48+
"os.environ[\"AWS_ACCESS_KEY_ID\"] = \"YOUR_AWS_ACCESS_KEY_ID_HERE\"\n",
49+
"os.environ[\"AWS_SECRET_ACCESS_KEY\"] = \"YOUR_AWS_SECRET_ACCESS_KEY_HERE\""
50+
]
51+
},
52+
{
53+
"cell_type": "markdown",
54+
"id": "6cbd3831",
55+
"metadata": {},
56+
"source": [
57+
"## 2. Configure Strands telemetry"
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"id": "c2062d8b",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"from strands.telemetry import StrandsTelemetry\n",
68+
"\n",
69+
"strands_telemetry = StrandsTelemetry()\n",
70+
"strands_telemetry.setup_otlp_exporter() # Send traces to OTLP endpoint\n",
71+
"strands_telemetry.setup_meter(enable_otlp_exporter=True) # Setup new meter provider\n"
72+
]
73+
},
74+
{
75+
"cell_type": "markdown",
76+
"id": "14982a12",
77+
"metadata": {},
78+
"source": [
79+
"## 3. Use Strands Agents normally\n",
80+
"\n",
81+
"All the traces will be captured and sent to Openlayer."
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"id": "524ec2e1",
88+
"metadata": {},
89+
"outputs": [],
90+
"source": [
91+
"from strands import Agent\n",
92+
"\n",
93+
"agent = Agent(\n",
94+
" model=\"us.anthropic.claude-sonnet-4-5-20250929-v1:0\",\n",
95+
" system_prompt=\"You are a helpful AI assistant\"\n",
96+
")"
97+
]
98+
},
99+
{
100+
"cell_type": "code",
101+
"execution_count": null,
102+
"id": "eb181016",
103+
"metadata": {},
104+
"outputs": [],
105+
"source": [
106+
"response = agent(\"What can you help me with?\")"
107+
]
108+
},
109+
{
110+
"cell_type": "code",
111+
"execution_count": null,
112+
"id": "5c626153",
113+
"metadata": {},
114+
"outputs": [],
115+
"source": []
116+
}
117+
],
118+
"metadata": {
119+
"kernelspec": {
120+
"display_name": "bedrock-test",
121+
"language": "python",
122+
"name": "python3"
123+
},
124+
"language_info": {
125+
"codemirror_mode": {
126+
"name": "ipython",
127+
"version": 3
128+
},
129+
"file_extension": ".py",
130+
"mimetype": "text/x-python",
131+
"name": "python",
132+
"nbconvert_exporter": "python",
133+
"pygments_lexer": "ipython3",
134+
"version": "3.12.3"
135+
}
136+
},
137+
"nbformat": 4,
138+
"nbformat_minor": 5
139+
}

0 commit comments

Comments
 (0)