Getting Started
Installation
Install the SDK with your preferred package manager:
bash
npm install one-agent-sdkbash
pnpm add one-agent-sdkbash
yarn add one-agent-sdkbash
bun add one-agent-sdkThen install the provider SDK for your backend:
bash
npm install @anthropic-ai/claude-agent-sdkbash
npm install @openai/codex-sdkbash
npm install @moonshot-ai/kimi-agent-sdkQuick 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?
- Learn about Agents and how to configure them
- See how to define Tools with type-safe parameters
- Understand the Streaming interface
- Build Multi-Agent Handoffs
- Compare Providers