Quickstart
Build your first AI agent with Astreus in under 2 minutes
Let's create a simple agent that can execute tasks and respond intelligently.
Before we proceed, make sure you have Astreus installed. If you haven't installed it yet, follow the installation guide.
Create Environment File
Create a .env
file in your project root and add your OpenAI API key:
touch .env
Add your API key to the .env
file:
OPENAI_API_KEY=sk-your-openai-api-key-here
Create your First Agent
Create an agent with memory and system prompt:
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-4o',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
Create and Execute Task
Create a task and execute it with your agent:
import { Agent } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-4o',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a task
const task = await agent.createTask({
prompt: "Research latest news in Anthropic and OpenAI"
});
// Execute the task
const result = await agent.executeTask(task.id);
console.log(result.response);
Build a Graph Workflow
Create a workflow graph with multiple tasks:
import { Agent, Graph } from '@astreus-ai/astreus';
// Create agent
const agent = await Agent.create({
name: 'ResearchAgent',
model: 'gpt-4o',
memory: true,
systemPrompt: 'You are an expert research assistant.'
});
// Create a graph for complex workflows
const graph = new Graph({
name: 'Research Pipeline',
defaultAgentId: agent.id
});
// Add task nodes
const researchNode = graph.addTaskNode({
prompt: 'Research the latest AI developments'
});
const analysisNode = graph.addTaskNode({
prompt: 'Analyze the research findings',
dependencies: [researchNode]
});
const summaryNode = graph.addTaskNode({
prompt: 'Create a summary report',
dependencies: [analysisNode]
});
// Run the graph
const graphResult = await graph.run();
console.log(graphResult.results[summaryNode]);
Congratulations! You've created your first AI agent with Astreus.
How is this guide?