Strands emits OpenTelemetry GenAI spans natively (agent cycles, model calls with tokens, tools). opentoken.init() sends them to Open Token; nothing else in your agent changes.
1. Install
pip install "getopentoken[strands]"2. Environment
Create an ingest key under API keys (scope Ingest) and export it as OT_INGEST_KEY. Your AWS credentials stay as they are.
# OT_INGEST_KEY: an ingest key from API keys (scope: Ingest). Keep it in your secret store.
export OTEL_EXPORTER_OTLP_ENDPOINT="https://getopentoken.com/api/otel"
export OTEL_SERVICE_NAME="support-agent"3. Add one line to your agent
import opentoken
opentoken.init() # Strands emits OpenTelemetry GenAI spans natively; this sends them to Open Token
from strands import Agent
from strands.models import BedrockModel
agent = Agent(model=BedrockModel(model_id="us.amazon.nova-lite-v1:0"), callback_handler=None)
with opentoken.context(feature="support", customer="acme"):
result = agent("Summarize our refund policy in one sentence.")
print(result)
opentoken.shutdown() # flush before a short-lived process exitsRun it, then open Traces: the run shows the agent, each model call with tokens and cost, and the feature and customer you set. You don't need StrandsTelemetry().setup_otlp_exporter(); if you already call it, keep it and init() adds Open Token to the same provider.
Enforce budgets through the gateway (optional)
To apply budgets and per-run limits, send the model calls through the gateway. If it's slow or down, calls go straight to Bedrock in your account and are still measured.
import opentoken
from opentoken.adapters.strands import openai_model
from strands import Agent
opentoken.init(base_url="https://getopentoken.com/v1")
agent = Agent(model=openai_model("amazon/nova-lite"), callback_handler=None)
with opentoken.context(feature="support"):
print(agent("Say hello in one sentence."))With BedrockModel, opentoken.adapters.strands.bedrock_model("<model id>") does the same while keeping Bedrock's native API on the direct path.
Also in Langfuse
Add OT_ALSO_EXPORT=langfuse and your LANGFUSE_* keys: the same trace reaches both. See SDK.