Your First Agent
Create your first AI agent with Astreus framework.
Quick Start#
Clone the Complete Example#
The easiest way to get started is to clone the complete example repository:
git clone https://github.com/astreus-ai/examples
cd examples/your-first-agent
npm installOr Install Package Only#
If you prefer to build from scratch:
npm install @astreus-ai/astreusEnvironment Setup#
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.dbBasic Agent#
import { Agent } from '@astreus-ai/astreus';
const agent = await Agent.create({
name: 'MyFirstAgent',
model: 'gpt-4o',
systemPrompt: 'You are a helpful assistant.'
});
// Create and execute a task
const task = await agent.createTask({
prompt: "Hello, introduce yourself"
});
const result = await agent.executeTask(task.id);
console.log(result.response);Running the Example#
If you cloned the repository:
npm run devIf you built from scratch, create an index.ts file with the code above and run:
npx tsx index.tsRepository#
The complete example is available on GitHub: examples/your-first-agent