Skip to main content
  1. Sign up — Create an account at platform.respan.ai
  2. Create an API key — Generate one on the API keys page
  3. Add credits or a provider key — Add credits on the Credits page or connect your own provider key on the Integrations page
Add the Docs MCP to your AI coding tool to get help building with Respan. No API key needed.
{
  "mcpServers": {
    "respan-docs": {
      "url": "https://docs.respan.ai/mcp"
    }
  }
}

What is Strands Agents?

Strands Agents is AWS’s open-source SDK for building AI agents. It provides a model-agnostic framework for creating agents with tool use, structured output, and multi-agent orchestration.

Setup

1

Install packages

pip install strands-agents respan-ai openinference-instrumentation-strands-agents python-dotenv
2

Set environment variables

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
export AWS_ACCESS_KEY_ID="YOUR_AWS_ACCESS_KEY"
export AWS_SECRET_ACCESS_KEY="YOUR_AWS_SECRET_KEY"
export AWS_REGION="us-east-1"
3

Initialize and run

import os
from dotenv import load_dotenv

load_dotenv()

from respan import Respan
from openinference.instrumentation.strands_agents import StrandsAgentsInstrumentor
from strands import Agent

# Initialize Respan with Strands Agents instrumentation
respan = Respan(instrumentations=[StrandsAgentsInstrumentor()])

agent = Agent(
    system_prompt="You are a helpful assistant.",
)

response = agent("What is the capital of France?")
print(response)
respan.flush()
4

View your trace

Open the Traces page to see your agent trace with LLM calls and tool spans.

Configuration

ParameterTypeDefaultDescription
api_keystr | NoneNoneFalls back to RESPAN_API_KEY env var.
base_urlstr | NoneNoneFalls back to RESPAN_BASE_URL env var.
instrumentationslist[]Plugin instrumentations to activate (e.g. StrandsAgentsInstrumentor()).
is_auto_instrumentbool | NoneFalseAuto-discover and activate all installed instrumentors via OpenTelemetry entry points.
customer_identifierstr | NoneNoneDefault customer identifier for all spans.
metadatadict | NoneNoneDefault metadata attached to all spans.
environmentstr | NoneNoneEnvironment tag (e.g. "production").

Attributes

In Respan()

Set defaults at initialization — these apply to all spans.
from respan import Respan
from openinference.instrumentation.strands_agents import StrandsAgentsInstrumentor

respan = Respan(
    instrumentations=[StrandsAgentsInstrumentor()],
    customer_identifier="user_123",
    metadata={"service": "strands-app", "version": "1.0.0"},
)

With propagate_attributes

Override per-request using a context manager.
from respan import Respan, workflow, propagate_attributes
from openinference.instrumentation.strands_agents import StrandsAgentsInstrumentor

respan = Respan(instrumentations=[StrandsAgentsInstrumentor()])

@workflow(name="handle_request")
def handle_request(user_id: str, question: str):
    with propagate_attributes(
        customer_identifier=user_id,
        thread_identifier="conv_001",
        metadata={"plan": "pro"},
    ):
        response = agent(question)
        print(response)
AttributeTypeDescription
customer_identifierstrIdentifies the end user in Respan analytics.
thread_identifierstrGroups related messages into a conversation.
metadatadictCustom key-value pairs. Merged with default metadata.

Decorators

Use @workflow and @task to create structured trace hierarchies.
from respan import Respan, workflow, task
from openinference.instrumentation.strands_agents import StrandsAgentsInstrumentor
from strands import Agent

respan = Respan(instrumentations=[StrandsAgentsInstrumentor()])

agent = Agent(system_prompt="You are a helpful assistant.")

@task(name="answer_question")
def answer_question(question: str) -> str:
    return str(agent(question))

@workflow(name="qa_pipeline")
def pipeline(question: str):
    answer = answer_question(question)
    print(answer)

pipeline("What are the benefits of LLM observability?")
respan.flush()

Examples

Basic agent

from strands import Agent

agent = Agent(
    system_prompt="You are a helpful assistant that answers questions concisely.",
)

response = agent("Explain machine learning in one sentence.")
print(response)