Skip to content

Getting Started

Installation

Install the SDK with your preferred package manager:

bash
npm install one-agent-sdk
bash
pnpm add one-agent-sdk
bash
yarn add one-agent-sdk
bash
bun add one-agent-sdk

Then install the provider SDK for your backend:

bash
npm install @anthropic-ai/claude-agent-sdk
bash
npm install @openai/codex-sdk
bash
npm install @moonshot-ai/kimi-agent-sdk

Quick Start

typescript
import { z } from "zod";
import { defineAgent, defineTool, run } from "one-agent-sdk";

// Define a tool
const weatherTool = defineTool({
  name: "get_weather",
  description: "Get the current weather for a city",
  parameters: z.object({
    city: z.string().describe("City name"),
  }),
  handler: async ({ city }) => {
    return JSON.stringify({ city, temperature: 72, condition: "sunny" });
  },
});

// Define an agent
const agent = defineAgent({
  name: "assistant",
  description: "A helpful assistant",
  prompt: "You are a helpful assistant. Use the weather tool when asked about weather.",
  tools: [weatherTool],
});

// Run — swap provider by changing this value
const { stream } = await run("What's the weather in San Francisco?", {
  provider: "claude", // "claude" | "codex" | "kimi"
  agent,
});

for await (const chunk of stream) {
  if (chunk.type === "text") {
    process.stdout.write(chunk.text);
  }
}

What's Next?