OpenAI Agents SDK
wrapOpenAI captures every chat.completions call as a traced run automatically. Add trust-platform calls around your function tools for identity, policy, and the audit chain.
TypeScript
import OpenAI from "openai";
import { ProofLedger, wrapOpenAI } from "@proofledger/sdk";
ProofLedger.enable({
apiKey: process.env.PROOFLEDGER_API_KEY,
agentName: "openai-sales-agent",
owner: "sales",
framework: "openai-agents",
model: "gpt-4.1",
});
await ProofLedger.registerAgent();
// Every completion call is traced (latency, tokens, cost) automatically:
const openai = wrapOpenAI(new OpenAI(), { agentId: "openai-sales-agent" });
const workflowId = "wf_lead_scoring_001";
// Your function tools log through the trust pipeline:
async function scoreLead(leadId: string) {
const { policy } = await ProofLedger.logToolCall({
workflowId,
toolName: "crm_lookup",
inputSummary: `leadId=${leadId}`,
});
if (policy.decision === "block") return { error: "blocked by policy" };
return crm.lookup(leadId);
}
const completion = await openai.chat.completions.create({
model: "gpt-4.1",
messages: [{ role: "user", content: "Score lead L-9917" }],
tools: [{ type: "function", function: { name: "scoreLead", /* … */ } }],
});
await ProofLedger.logWorkflowStep({
workflowId, status: "completed", action: "Lead scored",
});
await ProofLedger.flush();Python
import os
from openai import OpenAI
from proofledger import enable, register_agent, wrap_openai, log_tool_call
enable(api_key=os.environ["PROOFLEDGER_API_KEY"],
agent_name="openai-sales-agent", framework="openai-agents",
model="gpt-4.1")
register_agent()
openai = wrap_openai(OpenAI(), agent_id="openai-sales-agent")
def score_lead(lead_id: str):
result = log_tool_call("crm_lookup", workflow_id="wf_lead_scoring_001",
input_summary=f"leadId={lead_id}")
if result["policy"]["decision"] == "block":
return {"error": "blocked by policy"}
return crm.lookup(lead_id)Production
Approve crm_lookup in the Tools registry before enforce mode — and set sensitiveAction on anything that writes to the CRM.