leap360
v1.5.1
Published
Leap360 AI Governance SDK — trace, govern, and monitor AI agents across OpenAI, Anthropic, AWS Bedrock, Gemini, Mistral, and any LLM
Maintainers
Readme
🛡️ Leap360 SDK: The AI Governance Layer
Leap360 is a production-grade governance and observability SDK for AI-native applications. It provides real-time telemetry, automated policy enforcement, and a global Kill Switch that can halt AI operations project-wide in under 2 seconds.
📦 Installation
npm install leap360✅ Provider Support Matrix
| LLM SDK | Method | Auto-traced? |
|---|---|---|
| openai | Leap360.autoInit() or leap.wrapOpenAI() | ✅ Zero config |
| @google/generative-ai | Leap360.autoInit() or leap.wrapGemini() | ✅ Zero config |
| @google/genai (new SDK) | leap.wrapGoogleGenAI(client) | ✅ One line |
| @anthropic-ai/sdk | leap.wrapAnthropic(client) | ✅ One line |
| @aws-sdk/client-bedrock-runtime | leap.wrapBedrock(client) | ✅ One line |
| Mistral / any other LLM | leap.traceCall({ fn, provider, model }) | ✅ Manual |
🚀 Quick Setup
npx leap360 setupThis saves your API key to ~/.leap360/config.json and .env. Then:
import { Leap360 } from 'leap360';
const leap = Leap360.autoInit({
apiKey: process.env.LEAP360_API_KEY,
projectId: 'my-project',
serviceName: 'my-service',
});🛠️ Integration Examples
OpenAI — Zero config (autoInit)
import { Leap360 } from 'leap360';
import OpenAI from 'openai';
Leap360.autoInit({
apiKey: 'leap360_...',
projectId: 'my-project',
serviceName: 'chat-service',
});
// Every OpenAI call anywhere in your app is now auto-traced ✅
const openai = new OpenAI();
const res = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});OpenAI — Explicit wrap
import { Leap360 } from 'leap360';
import OpenAI from 'openai';
const leap = new Leap360({ apiKey: 'leap360_...', projectId: 'my-project', serviceName: 'chat' });
const openai = leap.wrapOpenAI(new OpenAI());
const res = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Hello!' }],
});Anthropic (Claude)
import { Leap360 } from 'leap360';
import Anthropic from '@anthropic-ai/sdk';
const leap = new Leap360({ apiKey: 'leap360_...', projectId: 'my-project', serviceName: 'claude-service' });
const anthropic = leap.wrapAnthropic(new Anthropic());
// All messages.create calls are now auto-traced ✅
const msg = await anthropic.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
messages: [{ role: 'user', content: 'Explain AI governance.' }],
});
console.log(msg.content[0].text);Note: Anthropic uses
input_tokens/output_tokensin its response — Leap360 maps these automatically toprompt_tokens/completion_tokensin the dashboard.
Google Gemini (@google/generative-ai)
import { Leap360 } from 'leap360';
import { GoogleGenerativeAI } from '@google/generative-ai';
const leap = new Leap360({ apiKey: 'leap360_...', projectId: 'my-project', serviceName: 'gemini-service' });
const genAI = leap.wrapGemini(new GoogleGenerativeAI(process.env.GEMINI_API_KEY));
const model = genAI.getGenerativeModel({ model: 'gemini-2.0-flash' });
const result = await model.generateContent('Hello!');
console.log(result.response.text());Google Gemini (@google/genai — new SDK)
import { Leap360 } from 'leap360';
import { GoogleGenAI } from '@google/genai';
const leap = new Leap360({ apiKey: 'leap360_...', projectId: 'my-project', serviceName: 'gemini-service' });
const ai = leap.wrapGoogleGenAI(new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY }));
const response = await ai.models.generateContent({
model: 'gemini-2.0-flash',
contents: 'Explain AI governance.',
});
console.log(response.text);AWS Bedrock
import { Leap360 } from 'leap360';
import { BedrockRuntimeClient, ConverseCommand } from '@aws-sdk/client-bedrock-runtime';
const leap = new Leap360({ apiKey: 'leap360_...', projectId: 'my-project', serviceName: 'bedrock-service' });
const bedrock = leap.wrapBedrock(new BedrockRuntimeClient({ region: 'us-east-1' }));
// Works with any Bedrock model: Claude, Titan, Nova, Llama, Mistral, Cohere
const res = await bedrock.send(new ConverseCommand({
modelId: 'amazon.nova-micro-v1:0', // ✅ Enabled by default in all AWS accounts
messages: [{ role: 'user', content: [{ text: 'Hello!' }] }],
}));
console.log(res.output.message.content[0].text);Supported Bedrock models:
| Model family | Example model ID | On-demand? |
|---|---|---|
| Amazon Nova | amazon.nova-micro-v1:0 | ✅ Yes (all accounts) |
| Amazon Nova | amazon.nova-lite-v1:0 | ✅ Yes (all accounts) |
| Amazon Nova | amazon.nova-pro-v1:0 | ✅ Yes (all accounts) |
| Anthropic Claude | anthropic.claude-3-5-sonnet-20241022-v2:0 | ⚠️ Provisioned throughput |
| Meta Llama | meta.llama3-70b-instruct-v1:0 | ✅ Yes |
| Mistral | mistral.mistral-large-2402-v1:0 | ✅ Yes |
| Cohere | cohere.command-r-plus-v1:0 | ✅ Yes |
💡 New to Bedrock? See the full end-to-end test example in
bedrock-test/— runs 4 scenarios with real AWS calls and traces everything to your Leap360 dashboard.
Mistral / Any Other LLM — Manual traceCall
import { Leap360Client } from 'leap360';
import MistralClient from '@mistralai/mistralai';
const leap = new Leap360Client({ apiKey: 'leap360_...' });
const mistral = new MistralClient(process.env.MISTRAL_API_KEY);
const result = await leap.traceCall({
provider: 'mistral',
model: 'mistral-large-latest',
fn: () => mistral.chat({ model: 'mistral-large-latest', messages: [{ role: 'user', content: 'Hello!' }] }),
extractUsage: (res) => ({
prompt_tokens: res.usage.prompt_tokens,
completion_tokens: res.usage.completion_tokens,
total_tokens: res.usage.total_tokens,
}),
});Named Agents (createAgent)
Tag all LLM calls with an agent name for per-agent cost and risk tracking:
const agent = leap.createAgent({ name: 'Legal-Compliance-Bot' });
await agent.run(async () => {
// All LLM calls inside this block are tagged as 'Legal-Compliance-Bot' ✅
const res = await openai.chat.completions.create({ model: 'gpt-4o', messages: [...] });
});📖 API Reference
Leap360.autoInit(config)
| Option | Type | Description |
|---|---|---|
| apiKey | string | Your Leap360 API key |
| projectId | string | Project ID from dashboard |
| serviceName | string | Label for this service |
| baseUrl | string | (Optional) Custom API endpoint |
Auto-detects and patches: OpenAI, @google/generative-ai, @anthropic-ai/sdk
leap.wrapOpenAI(client) → client
Wraps an openai OpenAI instance. All chat.completions.create calls are traced.
leap.wrapAnthropic(client) → client
Wraps an @anthropic-ai/sdk Anthropic instance. All messages.create calls are traced. Token fields (input_tokens/output_tokens) are mapped automatically.
leap.wrapBedrock(client) → client
Wraps an @aws-sdk/client-bedrock-runtime BedrockRuntimeClient. Intercepts send() for both ConverseCommand and InvokeModelCommand.
leap.wrapGemini(client) → client
Wraps a @google/generative-ai GoogleGenerativeAI instance.
leap.wrapGoogleGenAI(client) → client
Wraps a @google/genai GoogleGenAI instance (new SDK).
leap.traceCall(options) → result
Manually trace any LLM call. Options:
fn— async function to callprovider— e.g.'mistral','cohere','groq'model— model name stringextractUsage(result)— optional, return{ prompt_tokens, completion_tokens, total_tokens }
leap.createAgent({ name }) → { run(fn) }
Creates a named agent context. All calls inside agent.run(fn) are tagged with the agent name.
🛡️ Kill Switch
When autoInit is called, a background poller checks project/agent status every 15 seconds. If suspended:
Error: [Leap360] GOVERNANCE_HALT: AI interactions are suspended for this project.Wrap LLM calls in try/catch to handle gracefully.
🔒 Security & Privacy
- No proxy — your LLM traffic goes directly to the provider. Leap360 only receives metadata/telemetry out-of-band.
- API key auth — set
LEAP360_API_KEYenv var or usenpx leap360 login.
© 2026 Leap360. Automated AI Governance for the Agentic Era.
- Zero-Invasive Integration: Patch global prototypes to trace every LLM call in your app without changing a single line of your business logic.
- Hardened Resiliency: Our "Global Poller" heartbeat ensures that if a project is suspended in the dashboard, the SDK blocks outgoing LLM requests locally before they even transit the wire.
- Contextual Intelligence: Group calls into "Agents" (e.g., Legal-Bot, Finance-Bot) using
createAgentto understand cost and risk distribution across your fleet. - Universal Compatibility: Works in Node.js, Browsers, ESM, and CommonJS environments.
📦 Installation & Setup
npm install leap360Quick Setup (Recommended)
Run the interactive setup command - no browser login required!
npx leap360 setupThis will:
- Prompt for your API key (get from https://leap360.ai/dashboard/settings)
- Set project ID and service name
- Save to
~/.leap360/config.json(SDK config) - Create/update
.envfile with all variables - Add Gemini API keys for policy evaluation
Example:
🔐 Leap360 Setup
Enter your API key: leap360_09ff941583c7...
Enter project ID (default: default): my-project
Enter service name (default: my-service): api-service
✅ Configuration saved!
→ ~/.leap360/config.json
→ ./.envThen in your code:
import { Leap360 } from 'leap360';
const leap = Leap360.autoInit(); // Loads from config files🛠️ Integration Styles
1. The "Magic" 1-Line Integration (autoInit)
The fastest way to get started after running npx leap360 setup.
import { Leap360 } from 'leap360';
// Auto-loads from ~/.leap360/config.json and process.env
const leap = Leap360.autoInit();
// Or provide explicit config:
Leap360.autoInit({
apiKey: 'leap360_...',
projectId: 'my-production-app',
serviceName: 'enterprise-fleet'
});
// Now, any OpenAI or Gemini call anywhere in your app is automatically governed!2. The "Contextual" Agent Approach (createAgent)
Use this to tag calls with specific agent names. This uses AsyncLocalStorage (Node) or a fallback (Browser) to propagate context.
const agent = leap.createAgent({ name: 'Legal-Compliance-Bot' });
await agent.run(async () => {
// All LLM calls inside this block are tagged as 'Legal-Compliance-Bot'
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-pro' });
await model.generateContent("Analyze this contract...");
});3. Manual Instance Wrapping
For developers who prefer explicit control over specific client instances.
const openai = leap.wrapOpenAI(new OpenAI());
// Legacy Google Generative AI
const genAI = leap.wrapGemini(new GoogleGenerativeAI(apiKey));
// NEW: Google GenAI Client (google-genai package)
import genai from 'google-genai';
const client = leap.wrapGoogleGenAI(new genai.Client());
const response = await client.models.generate_content({
model: 'gemini-3-flash-preview',
contents: 'Explain quantum computing'
});4. Low-Level Manual Tracing (Leap360Client)
For non-standard models or custom wrappers where you want full control over the trace payload.
import { Leap360Client } from 'leap360';
const client = new Leap360Client({ apiKey: '...' });
const result = await client.traceCall({
provider: 'anthropic',
model: 'claude-3-opus',
fn: async () => myCustomCall(),
extractUsage: (res) => ({ prompt_tokens: 10, completion_tokens: 20, total_tokens: 30 })
});🔍 Detailed Functionality
📡 Real-Time Kill Switch (The Heartbeat)
When autoInit is called, the SDK spawns a background poller that hits the Leap360 Governance API every 2 seconds.
- Operation: If the API returns
SUSPENDED, the SDK sets a globalisHaltedflag. - Enforcement: Every wrapped LLM call checks this flag before execution. If true, it throws a
GOVERNANCE_HALTerror. - Heartbeat Recovery: The moment a project is resumed in the dashboard, the 2s heartbeat detects the change and unblocks the SDK instantly.
🧪 Global Prototype Patching
The SDK uses a sophisticated patching strategy to find AI libraries regardless of how they are imported:
- Global Search: Checks
globalThisforOpenAIorGoogleGenerativeAI. - Dynamic ESM Import: Uses robust
import()logic to locate and wrap prototypes after modules have loaded in modern ESM environments. - Cross-Platform Storage: Uses
node:async_hooksin Node.js for thread-safe context and a browser-safe fallback for frontend apps.
📊 Automated Telemetry
Every trace captured by Leap360 includes:
- Latency: Precise millisecond timing of the round-trip.
- Token Counting: Automatic extraction of usage stats from OpenAI and Gemini response metadata.
- Payload Capture: Full request/response JSON (sanitized via backend policies).
- Error Tracking: Capture stack traces and error messages for failed AI calls.
📖 API Reference
Leap360.autoInit(config: Leap360Config)
| Option | Type | Description |
| :--- | :--- | :--- |
| apiKey | string | Your project-scoped Leap360 API Key. |
| projectId | string | The ID of the project in your dashboard. |
| serviceName | string | A label for this specific deployment/service. |
| baseUrl | string | (Optional) Custom governance API endpoint. |
agent.run(fn)
Wraps an async function in a context. Every LLM call triggered within the closure of fn will inherit the agent's properties.
traceCall(options)
Low-level wrapper for custom LLM interactions.
fn: The async function to execute.extractUsage: A callback to parse tokens from the result.metadata: Any custom JSON to attach to the trace.
🛡️ Errors & Handling
When the Kill Switch is active, the SDK throws a standard Error:
Error: [Leap360] GOVERNANCE_HALT: AI interactions are suspended for this project.You should wrap your LLM calls in try/catch and handle this specific error to provide a fallback UX to your users.
🔒 Security & Privacy
- Sanitization: Sensitive data can be filtered at the SDK level (using
metadataoverrides) or via Backend Policies in the Leap360 dashboard. - No-Proxy Architecture: Unlike other tools, Leap360 does not proxy your traffic through our servers. Your API keys and data transit directly to the provider; we only receive metadata/telemetry out-of-band.
© 2026 Leap360. Automated AI Governance for the Agentic Era.
