SDK Reference
Core SDK configuration, decorators, and context management.
The Risicare SDK provides automatic and manual instrumentation for your AI agents.
Quick Links
Configuration
init() options and environment variables
Learn more
Decorators
@agent, @session, @trace_* decorators
Learn more
Context
Context propagation and managers
Learn more
Installation
pip install risicareBasic 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
| Function | Description |
|---|---|
init(**config) | Initialize the SDK with configuration |
shutdown() | Gracefully shutdown and flush pending spans |
get_client() | Get the global Risicare client instance |
Decorators
| Decorator | Description |
|---|---|
@agent() | Mark function as an agent |
@session() | Extract session from arguments |
@trace_think | Mark as THINK phase |
@trace_decide | Mark as DECIDE phase |
@trace_act | Mark as ACT phase |
@trace_observe | Mark as OBSERVE phase |
@trace_message | Track inter-agent messages |
@trace_delegate | Track task delegation |
@trace_coordinate | Track coordination |
Context Managers
| Context Manager | Description |
|---|---|
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
| Method | Description |
|---|---|
get_tracer() | Get the global tracer |
start_span(name) | Start a new span |
Configuration Options
See Configuration for all options.