Your First Agent

Example

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/your-first-agent
cd your-first-agent
npm install

Or Install Package Only

If you prefer to build from scratch:

npm install @astreus-ai/astreus

Environment Setup

# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db

Basic 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 dev

If you built from scratch, create an index.ts file with the code above and run:

npx tsx index.ts

Repository

The complete example is available on GitHub: astreus-ai/your-first-agent

How is this guide?