Python SDK
The leap360 Python package, version 1.3.0.
pip install leap360Python 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):
...| Option | Default | Description |
|---|---|---|
mode | From the console | "shadow" or "enforce" |
fail_closed_at | "critical" | When Leap360 can't be reached, block calls at this risk or above |
approval_wait | 0 | Seconds to wait for a person to approve a held call |
status_ttl | 1.0 | Seconds a kill switch status is reused |
timeout | 2.0 | Seconds 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.
| Method | What 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
| Field | Type | Description |
|---|---|---|
model | str | Model identifier (required) |
provider | str | bedrock, openai, anthropic, gemini, azure, mistral, cohere |
service_name | str | Agent or service name |
agent_name | str | Named agent, distinct from service_name |
run_id | str | Group traces into one run |
latency_ms | int | Latency in milliseconds |
usage | dict | prompt_tokens, completion_tokens, total_tokens |
request, response | dict | What was sent and received |
error | str | Error message if the call failed |
timestamp | str | ISO 8601; defaults to now |