Python SDK Reference

Complete API reference for the RunLog AI Python SDK. Add full observability with just 1 decorator per function.

Installation
pip install runlog-ai

API Methods

@runlog
Decorator for automatic observability and control

Signature

@runlog(service: str, env: str = 'development', policies: str = None)

Example

@runlog(service="my-agent", env="production")
def my_agent_function(user_input: str):
    # Your existing code stays the same
    response = llm.generate(prompt=user_input)
    return response
runlog.configure()
Global configuration for the SDK

Signature

configure(api_key: str, base_url: str = None)

Example

import runlog

runlog.configure(
    api_key="rl_your_api_key_here",
    base_url="https://api.runlogai.com"  # Optional
)
Manual Tracking
Optional manual tracking for advanced use cases

Signature

with runlog.run(task: str, **kwargs)

Example

# Only needed for complex workflows
with runlog.run(task="multi-step-process"):
    step1 = runlog.tool("api_call", endpoint="/search")
    step2 = runlog.tool("llm_call", model="gpt-4")
    return combine_results(step1, step2)
Policy Integration
Automatic policy enforcement with decorators

Signature

@runlog(..., policies: str)

Example

@runlog(service="banking", policies="./banking_policies.yaml")
def process_transaction(amount: float, account_id: str):
    # Policies automatically enforced
    return execute_transaction(amount, account_id)
Configuration Options
Available configuration parameters

Environment Variables

RUNLOG_API_KEYYour API key
RUNLOG_BASE_URLAPI base URL

Client Options

timeoutRequest timeout
retry_countRetry attempts