Skip to content
AgentField
SDKs

TypeScript SDK

Full API reference for @agentfield/sdk — the TypeScript SDK for building AI agents on AgentField.

TypeScript SDK — npm install @agentfield/sdk

Build AI agents as production microservices with TypeScript.

The @agentfield/sdk package lets you build, deploy, and orchestrate AI agents in TypeScript and JavaScript. Registered reasoners and skills are exposed through the agent runtime, and DID-backed identity is available when enabled in config. Runs on Node.js 18+.

Install

npm install @agentfield/sdk

Requires Node.js 18+. The package uses native ESM -- set "type": "module" in your package.json.

Quick Start

import { Agent } from "@agentfield/sdk";
import { z } from "zod";

const agent = new Agent({
  nodeId: "my-agent",
  aiConfig: {
    provider: "openai",
    model: "gpt-4o",
  },
});

agent.reasoner("greet", async (ctx) => {
  const response = await ctx.ai("Say hello to the user.", {
    system: "You are a friendly assistant.",
  });
  return { message: response };
});

agent.serve();

Start the control plane and your agent:

af server          # Terminal 1 — Dashboard at http://localhost:8080
npx tsx app.ts     # Terminal 2 — Agent auto-registers

In TypeScript, AI calls use ctx.ai() inside handler callbacks, NOT agent.ai() on the agent instance. The context object provides the full API surface.