Create AI agents with just a few lines of code. AINU provides the building blocks, you decide how to use them.
import { Agent, Anthropic, Tool } from "@ainu/ai";
import { z } from "zod";
async function main() {
// create the model provider
const provider = new Anthropic({
apiKey: "your-api-key",
});
// create a simple tool
const weather = new Tool("getWeather", {
description: "Get the weather at a given location",
parameters: z.object({ location: z.string() }),
handler: ({ location }) => 100,
});
// create the agent
const agent = new Agent({
provider,
tools: [weather],
settings: {
// optional agent settings
system: "You are a helpful and charming assistant",
},
});
// use the agent to generateText
const response = await agent.generateText({
prompt: "Hello, how are you?",
maxSteps: 3,
});
console.log(response.data?.text);
}
main();