Skip to main content
GitHub

SDK Reference

Core SDK configuration, decorators, and context management.

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

Installation

pip install risicare

Basic Usage

import risicare
from risicare import agent, trace_think, trace_act
 
# Initialize the SDK
risicare.init(
    api_key="rsk-your-api-key",
    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
shutdown()Gracefully shutdown and flush pending spans
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
start_span()Create a custom span

Tracer

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

Configuration Options

See Configuration for all options.

Next Steps