SDKs Overview
OpenSearch AgentHealth provides official SDKs for instrumenting your AI agents with observability and evaluation capabilities.
Available SDKs
Section titled βAvailable SDKsβPython SDK
Section titled βPython SDKβFull-featured SDK for Python applications. Supports all major agent frameworks.
JavaScript/TypeScript SDK
Section titled βJavaScript/TypeScript SDKβNative support for Node.js and browser environments.
JavaScript SDK Documentation β
Quick Start
Section titled βQuick Startβpip install opensearch-agentopsfrom opensearch_agentops import AgentHealth
# Initializeagentops = AgentHealth( endpoint="http://localhost:4317", # OTEL Collector service_name="my-agent")
# Instrument your agent@agentops.tracedef run_agent(prompt: str): # Your agent logic here response = my_llm.generate(prompt) return response
# Automatic tracing captures:# - LLM calls with token usage# - Tool invocations# - Execution timingJavaScript
Section titled βJavaScriptβnpm install @opensearch-project/agentopsimport { AgentHealth } from '@opensearch-project/agentops';
// Initializeconst agentops = new AgentHealth({ endpoint: 'http://localhost:4317', serviceName: 'my-agent'});
// Instrument your agentconst result = await agentops.trace('agent_run', async (span) => { // Your agent logic here const response = await myLLM.generate(prompt);
// Add custom attributes span.setAttribute('gen_ai.request.model', 'claude-sonnet-4');
return response;});Core Features
Section titled βCore FeaturesβAutomatic Instrumentation
Section titled βAutomatic InstrumentationβThe SDKs automatically capture:
| Data | Description | OTEL Attribute |
|---|---|---|
| Model Info | LLM provider and model ID | gen_ai.system, gen_ai.request.model |
| Token Usage | Input/output token counts | gen_ai.usage.input_tokens |
| Tool Calls | Function invocations | gen_ai.tool.name |
| Latency | Execution timing | Span duration |
| Errors | Exceptions and failures | exception.* |
Agent Adapters
Section titled βAgent AdaptersβSDKs support multiple agent frameworks through adapters:
from opensearch_agentops.adapters import ( LangGraphAdapter, StrandsAdapter, ClaudeCodeAdapter, CustomAdapter)
# LangGraph integrationadapter = LangGraphAdapter( endpoint="http://localhost:3000", streaming=True)
# Strands integration (AWS Bedrock)adapter = StrandsAdapter( agent_id="my-strands-agent", region="us-west-2")
# Custom agentadapter = CustomAdapter( execute_fn=my_agent_function)Multi-Agent Comparison
Section titled βMulti-Agent ComparisonβCompare different agent configurations:
# Define agent configurationsconfigs = [ {"agent": "langgraph", "model": "claude-sonnet-4"}, {"agent": "langgraph", "model": "gpt-4o"}, {"agent": "strands", "model": "claude-sonnet-4"},]
# Run comparisoncomparison = agentops.compare_agents( test_case_id="tc-database-timeout", configs=configs)
# Analyze resultsprint(f"Best performing: {comparison.best_config}")print(f"Accuracy comparison:")for result in comparison.results: print(f" {result.config}: {result.accuracy}/100")Evaluation API
Section titled βEvaluation APIβRun evaluations programmatically:
# Create test casetest_case = agentops.create_test_case( name="Database Timeout Diagnosis", initial_prompt="Why is my API returning 503 errors?", context=[ {"type": "log", "content": "Connection timeout errors..."}, {"type": "metric", "content": {"pool_size": [45, 48, 50, 50]}} ], expected_outcomes=[ "Identify connection pool exhaustion", "Recommend increasing pool size" ])
# Create benchmarkbenchmark = agentops.create_benchmark( name="RCA Suite", test_case_ids=[test_case.id])
# Run evaluationrun = agentops.run_benchmark( benchmark_id=benchmark.id, agent="langgraph", model="claude-sonnet-4")
# Get resultsprint(f"Pass Rate: {run.metrics.pass_rate}%")print(f"Avg Accuracy: {run.metrics.avg_accuracy}")
# Access individual resultsfor result in run.results: print(f"{result.test_case_name}: {result.pass_fail_status}") print(f" Accuracy: {result.accuracy}") print(f" Reasoning: {result.llm_judge_reasoning}")Framework Integrations
Section titled βFramework IntegrationsβLangGraph
Section titled βLangGraphβfrom opensearch_agentops.integrations import LangGraphInstrumentation
# Auto-instrument LangGraphLangGraphInstrumentation.instrument()
# Your LangGraph code is now traced automaticallyfrom langgraph.prebuilt import create_react_agent
agent = create_react_agent(model, tools)result = agent.invoke({"messages": [("user", prompt)]})Strands
Section titled βStrandsβfrom opensearch_agentops.integrations import StrandsInstrumentation
# Auto-instrument StrandsStrandsInstrumentation.instrument()
# Strands agents are now tracedfrom strands import Agent
agent = Agent(model="claude-sonnet-4")result = agent.run(prompt)from opensearch_agentops.integrations import OpenAIInstrumentation
# Auto-instrument OpenAIOpenAIInstrumentation.instrument()
# OpenAI calls are now tracedfrom openai import OpenAI
client = OpenAI()response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": prompt}])Anthropic
Section titled βAnthropicβfrom opensearch_agentops.integrations import AnthropicInstrumentation
# Auto-instrument AnthropicAnthropicInstrumentation.instrument()
# Anthropic calls are now tracedimport anthropic
client = anthropic.Anthropic()response = client.messages.create( model="claude-sonnet-4-20250514", messages=[{"role": "user", "content": prompt}])Configuration
Section titled βConfigurationβEnvironment Variables
Section titled βEnvironment Variablesβ# RequiredAGENTOPS_ENDPOINT=http://localhost:4317
# OptionalAGENTOPS_SERVICE_NAME=my-agentAGENTOPS_ENVIRONMENT=productionAGENTOPS_DEBUG=false
# LLM JudgeAGENTOPS_JUDGE_MODEL=claude-sonnet-4AGENTOPS_JUDGE_PROVIDER=bedrock # or openai, anthropic
# OpenSearch StorageOPENSEARCH_URL=http://localhost:9200OPENSEARCH_USERNAME=adminOPENSEARCH_PASSWORD=adminProgrammatic Configuration
Section titled βProgrammatic Configurationβfrom opensearch_agentops import AgentHealth, Config
config = Config( endpoint="http://localhost:4317", service_name="my-agent", environment="production",
# Sampling trace_sample_rate=1.0, # 100% sampling
# Batching batch_size=100, flush_interval=5000, # 5 seconds
# Judge settings judge_model="claude-sonnet-4", judge_provider="bedrock")
agentops = AgentHealth(config=config)SDK Architecture
Section titled βSDK Architectureββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Your Application βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€β AgentHealth SDK ββ ββββββββββββββ ββββββββββββββ ββββββββββββββ ββ β Tracers β β Adapters β β Evaluators β ββ βββββββ¬βββββββ βββββββ¬βββββββ βββββββ¬βββββββ ββ β β β ββ βββββββββββββββββ΄ββββββββββββββββ ββ β ββ βββββββββββ΄ββββββββββ ββ β OTEL Exporter β ββ βββββββββββ¬ββββββββββ βββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ β OTLP gRPC/HTTP βΌ ββββββββββββββββββββββββ β OTEL Collector β ββββββββββββ¬ββββββββββββ β βββββββββββββββΌββββββββββββββ βΌ βΌ βΌ ββββββββββββ ββββββββββββ ββββββββββββ βOpenSearchβ βPrometheusβ β Jaeger β ββββββββββββ ββββββββββββ ββββββββββββNext Steps
Section titled βNext StepsβPython SDK
Section titled βPython SDKβComplete Python SDK reference β
JavaScript SDK
Section titled βJavaScript SDKβComplete JavaScript SDK reference β