Skip to main content
Your LLM invokes tools through OpenAI or Anthropic function calling. You want each tool invocation guarded and traced without building a full framework integration.

OpenAI tool calls

import { withOpenAIToolCall } from "@apie-sh/sdk";

await apie.withRun({ inputSummary: "Process request" }, async (run) => {
  await withOpenAIToolCall(
    apie,
    {
      runId: run.id,
      toolName: "summarize_release_risk",
      arguments: { service: "api", environment: "production" },
      resourceType: "work_item",
      riskLevel: "medium",
    },
    async () => ({ summary: "No blocker found." }),
  );
});

Anthropic tool calls

import { withAnthropicToolCall } from "@apie-sh/sdk";

await withAnthropicToolCall(
  apie,
  {
    runId: run.id,
    toolName: "search",
    arguments: { query: "incident timeline" },
    resourceType: "knowledge_base",
  },
  async () => search("incident timeline"),
);

Generic tool call guard

For any LLM provider’s tool call format:
import { withToolCallGuard } from "@apie-sh/sdk";

await withToolCallGuard(
  apie,
  {
    runId: run.id,
    toolName: "custom_tool",
    actionType: "execute",
    resourceType: "pipeline_run",
    environment: "production",
    riskLevel: "high",
  },
  async () => customTool.execute(),
);

What you’ll see

agent.tool.called events with tool name, arguments summary, and guard evaluation results.

Production release gate example

See Production release gate recipe for withOpenAIToolCall and withMcpToolCall in a pipeline session.

Next steps

Instrument tool calls

General tool instrumentation.

OpenAI Agents

Full Agents SDK hooks.