Skip to main content

SDK Reference

Core SDK configuration, decorators, and context management.

The Risicare SDK provides automatic and manual instrumentation for your AI agents.

Python SDK

JavaScript / TypeScript SDK

Installation

pip install risicare

Basic Usage

import risicare
from risicare import agent, trace_think, trace_act
 
# Initialize the SDK. The key comes from RISICARE_API_KEY.
risicare.init(
    environment="production",
)
 
# Define an agent
@agent(name="planner", role="orchestrator")
async def plan_and_execute(objective: str):
    plan = await think_about_plan(objective)
    result = await execute_plan(plan)
    return result
 
@trace_think
async def think_about_plan(objective: str):
    # LLM calls here are automatically traced
    response = await client.chat.completions.create(...)
    return response.choices[0].message.content
 
@trace_act
async def execute_plan(plan: str):
    # Action execution
    return await run_tools(plan)

Public API

Initialization

FunctionDescription
init(**config)Initialize the SDK with configuration
flush()Wait until the gateway accepted the queued spans. Returns True when it did. The SDK stays active
shutdown()Send the queued spans and stop the SDK. Call it only where the process ends
get_client()Get the global Risicare client instance

Decorators

DecoratorDescription
@agent()Mark function as an agent
@session()Extract session from arguments
@trace_thinkMark as THINK phase
@trace_decideMark as DECIDE phase
@trace_actMark as ACT phase
@trace_observeMark as OBSERVE phase
@trace_messageTrack inter-agent messages
@trace_delegateTrack task delegation
@trace_coordinateTrack coordination

Context Managers

Context ManagerDescription
session_context()Create a session context
agent_context()Create an agent context
phase_context()Create a phase context

For a custom span context, use tracer.start_span() (see Tracer below) — there is no span_context() export.

Tracer

MethodDescription
get_tracer()Get the global tracer
tracer.start_span(name)Start a new span via the tracer instance

Configuration Options

See Configuration for all options.

Next Steps