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:

bash
git clone https://github.com/astreus-ai/examples
cd examples/your-first-agent
npm install

Or Install Package Only#

If you prefer to build from scratch:

bash
npm install @astreus-ai/astreus

Environment Setup#

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

Basic Agent#

typescript
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:

bash
npm run dev

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

bash
npx tsx index.ts

Repository#

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