Loading...
Loading...
Skill for creating AI agent projects using the VoltAgent framework. Guide for CLI setup and manual bootstrapping.
npx skill4agent add voltagent/skills create-voltagentnpm create voltagent-app@latestnpm create voltagent-app@latestpnpm create voltagent-app@latest
yarn create voltagent-app@latest
bun create voltagent-app@latestmy-voltagent-app.envREADME.mdtsconfig.jsontsdown.config.tsnpm create voltagent-app@latestcd <your-project-directory>
npm run devollama pull llama3.2npm create voltagent-app@latest my-voltagent-appnpm create voltagent-app@latest -- --example with-workflowpnpm create voltagent-app@latest -- --example with-workflow
yarn create voltagent-app@latest -- --example with-workflow
bun create voltagent-app@latest -- --example with-workflow----examplenpm installnpm run devmy-voltagent-app/
|-- src/
| |-- index.ts
| |-- tools/
| | |-- index.ts
| | `-- weather.ts
| `-- workflows/
| `-- index.ts
|-- .env
|-- .voltagent/
|-- Dockerfile
|-- .dockerignore
|-- .gitignore
|-- README.md
|-- package.json
|-- tsconfig.json
`-- tsdown.config.tspackages/core/docs.envOPENAI_API_KEY=...
ANTHROPIC_API_KEY=...
GOOGLE_GENERATIVE_AI_API_KEY=...
GROQ_API_KEY=...
MISTRAL_API_KEY=...
OLLAMA_HOST=http://localhost:11434
VOLTAGENT_PUBLIC_KEY=...
VOLTAGENT_SECRET_KEY=...mkdir my-voltagent-app && cd my-voltagent-app
npm init -y
mkdir -p src/tools src/workflows .voltagentnpm install @voltagent/core @voltagent/libsql @voltagent/logger @voltagent/server-hono @voltagent/cli ai zod dotenvnpm install @voltagent/core @voltagent/libsql @voltagent/logger @voltagent/server-elysia @voltagent/cli ai zod dotenvnpm install -D typescript tsx tsdown @types/node @biomejs/biome{
"scripts": {
"dev": "tsx watch --env-file=.env ./src",
"build": "tsdown",
"start": "node dist/index.js",
"lint": "biome check ./src",
"lint:fix": "biome check --write ./src",
"typecheck": "tsc --noEmit",
"volt": "volt"
}
}voltinitdeployevalpromptstunnelupdatetsconfig.json{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"outDir": "dist",
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}tsdown.config.tsimport { defineConfig } from "tsdown";
export default defineConfig({
entry: ["./src/index.ts"],
sourcemap: true,
outDir: "dist",
});OPENAI_API_KEY=your-api-key-here
VOLTAGENT_PUBLIC_KEY=your-public-key
VOLTAGENT_SECRET_KEY=your-secret-key
NODE_ENV=developmentOLLAMA_HOST=http://localhost:11434src/tools/weather.tsimport { createTool } from "@voltagent/core";
import { z } from "zod";
export const weatherTool = createTool({
name: "getWeather",
description: "Get the current weather for a specific location",
parameters: z.object({
location: z.string().describe("City or location to get weather for"),
}),
execute: async ({ location }) => {
return {
weather: {
location,
temperature: 21,
condition: "Sunny",
humidity: 45,
windSpeed: 8,
},
message: `Current weather in ${location}: 21 C and sunny.`,
};
},
});src/tools/index.tsexport { weatherTool } from "./weather";src/workflows/index.tsimport { createWorkflowChain } from "@voltagent/core";
import { z } from "zod";
export const expenseApprovalWorkflow = createWorkflowChain({
id: "expense-approval",
name: "Expense Approval Workflow",
purpose: "Process expense reports with manager approval for high amounts",
input: z.object({
employeeId: z.string(),
amount: z.number(),
category: z.string(),
description: z.string(),
}),
result: z.object({
status: z.enum(["approved", "rejected"]),
approvedBy: z.string(),
finalAmount: z.number(),
}),
})
.andThen({
id: "check-approval-needed",
resumeSchema: z.object({
approved: z.boolean(),
managerId: z.string(),
comments: z.string().optional(),
adjustedAmount: z.number().optional(),
}),
execute: async ({ data, suspend, resumeData }) => {
if (resumeData) {
return {
...data,
approved: resumeData.approved,
approvedBy: resumeData.managerId,
finalAmount: resumeData.adjustedAmount || data.amount,
managerComments: resumeData.comments,
};
}
if (data.amount > 500) {
await suspend("Manager approval required", {
employeeId: data.employeeId,
requestedAmount: data.amount,
category: data.category,
});
}
return {
...data,
approved: true,
approvedBy: "system",
finalAmount: data.amount,
};
},
})
.andThen({
id: "process-decision",
execute: async ({ data }) => {
return {
status: data.approved ? "approved" : "rejected",
approvedBy: data.approvedBy,
finalAmount: data.finalAmount,
};
},
});src/index.tsimport "dotenv/config";
import {
Agent,
Memory,
VoltAgent,
VoltAgentObservability,
VoltOpsClient,
} from "@voltagent/core";
import { LibSQLMemoryAdapter, LibSQLObservabilityAdapter } from "@voltagent/libsql";
import { createPinoLogger } from "@voltagent/logger";
import { honoServer } from "@voltagent/server-hono";
import { expenseApprovalWorkflow } from "./workflows";
import { weatherTool } from "./tools";
const logger = createPinoLogger({ name: "my-voltagent-app", level: "info" });
const memory = new Memory({
storage: new LibSQLMemoryAdapter({
url: "file:./.voltagent/memory.db",
logger: logger.child({ component: "libsql" }),
}),
});
const observability = new VoltAgentObservability({
storage: new LibSQLObservabilityAdapter({
url: "file:./.voltagent/observability.db",
}),
});
const agent = new Agent({
name: "my-voltagent-app",
instructions: "A helpful assistant that can check weather and help with various tasks",
model: "openai/gpt-4o-mini",
tools: [weatherTool],
memory,
});
new VoltAgent({
agents: { agent },
workflows: { expenseApprovalWorkflow },
server: honoServer(),
logger,
observability,
voltOpsClient: new VoltOpsClient({
publicKey: process.env.VOLTAGENT_PUBLIC_KEY || "",
secretKey: process.env.VOLTAGENT_SECRET_KEY || "",
}),
});provider/modelopenai/gpt-4o-minianthropic/claude-3-5-sonnetgoogle/gemini-2.0-flashgroq/llama-3.3-70b-versatilemistral/mistral-large-latestollama/llama3.2honoServerelysiaServernpm run dev