Docs

Tools

Give AxAgent your own functions to call, with optional human approval.

A tool is a function in your code that the agent can call during a run. Use tools to give the agent access to your own systems, such as your database or payments provider.

Coming Q4 2026

The SDK ships with AxAgent. The API below may change before launch.

Define a tool

Use tool() from the SDK. The input schema takes a Standard Schema, such as Zod, so execute receives typed input.

tools.ts
import { tool } from '@axerity/sdk'
import { z } from 'zod'

const getOrder = tool({
  name: 'get_order',
  description: 'Look up an order by its ID',
  input: z.object({ orderId: z.string() }),
  execute: ({ orderId }) => db.orders.find(orderId),
})

Prop

Type

Pass tools to a run

const run = await axerity.runs.create({
  agent: agent.id,
  input: 'Where is order #4821?',
  tools: [getOrder],
})

Require approval

Set needsApproval: true on tools that should not run without a person checking first, such as refunds or deletes. When the agent calls one, the run stops with status requires_approval and lists the calls in pendingToolCalls.

Mark the tool with needsApproval: true.

Check for run.status === 'requires_approval'.

Approve the pending call with axerity.runs.approve().

approvals.ts
import Axerity, { tool } from '@axerity/sdk'
import { z } from 'zod'

const axerity = new Axerity()

const refundOrder = tool({
  name: 'refund_order',
  description: 'Refund an order',
  input: z.object({ orderId: z.string(), reason: z.string() }),
  needsApproval: true,
  execute: ({ orderId, reason }) => payments.refund(orderId, reason),
})

const run = await axerity.runs.create({
  agent: agent.id,
  input: 'Order #4821 arrived broken, please refund it',
  tools: [getOrder, refundOrder],
})

if (run.status === 'requires_approval') {
  await axerity.runs.approve(run.id, {
    toolCall: run.pendingToolCalls[0].id,
  })
}

When you stream a run, each call shows up as a tool.called event and each result as a tool.completed event.

On this page