Leap360Leap360DocsBeta

Python SDK

The leap360 Python package, version 1.3.0.

pip install leap360

Python 3.8 or later.

Leap360Governor

Governs the functions an agent can call. See Govern tool calls.

from leap360 import Leap360Governor, ActionBlocked

gov = Leap360Governor(agent_name="deploy-bot")

@gov.wrap_tool("delete_namespace")
def delete_namespace(name: str):
    ...
OptionDefaultDescription
modeFrom the console"shadow" or "enforce"
fail_closed_at"critical"When Leap360 can't be reached, block calls at this risk or above
approval_wait0Seconds to wait for a person to approve a held call
status_ttl1.0Seconds a kill switch status is reused
timeout2.0Seconds to wait for Leap360

Leap360Tracer

Wraps a model client so every call is traced in the background.

import openai
from leap360 import Leap360Tracer

tracer = Leap360Tracer(service_name="search")   # reads LEAP360_API_KEY
client = tracer.wrap(openai.OpenAI())           # OpenAI, Anthropic, Gemini and Bedrock clients
client.chat.completions.create(model="gpt-4o", messages=[...])

For any other provider, tracer.trace_call(fn, provider=..., model=..., extract_usage=...) runs fn and traces it.

Leap360

The API client.

Leap360(api_key=None, base_url=None, project_id="me", timeout=10.0)

Without api_key it reads LEAP360_API_KEY, then ~/.leap360/config.json. Every method returns the API's JSON. Errors are returned, not raised: the dict carries error, code and http_status.

MethodWhat it does
trace(model, **fields)Send a trace
get_stats(), get_traces(limit=50, offset=0), get_models(), get_audit()Project activity
get_agents(), get_agent_status(agent_id)Agents and their kill switch
suspend_agent(agent_id), resume_agent(agent_id)Stop or restart one agent (restart needs a signed-in person)
get_project_status(), set_project_status(status)The project kill switch
get_policies(), create_policy(policy), get_violations()Policies
get_approvals(), decide_approval(trace_id, decision, note=None)The approval queue
get_mode(), set_mode(mode, days=None)Shadow mode; shadow can run 1 to 30 days
get_shadow_report()What policies would have blocked and suggested policies
get_actions(limit=100, since=None)Recorded tool calls (default: the last 7 days)
get_scans()Uploaded code scans

trace fields

FieldTypeDescription
modelstrModel identifier (required)
providerstrbedrock, openai, anthropic, gemini, azure, mistral, cohere
service_namestrAgent or service name
agent_namestrNamed agent, distinct from service_name
run_idstrGroup traces into one run
latency_msintLatency in milliseconds
usagedictprompt_tokens, completion_tokens, total_tokens
request, responsedictWhat was sent and received
errorstrError message if the call failed
timestampstrISO 8601; defaults to now

On this page