Building AI agents doesn't need to be complicated. With Astreus, you can create a working agent in just a few lines of code. This tutorial covers the fundamentals using the real Astreus API.
Quick Start
You can clone the complete example or start from scratch:
Or install just the package:
Environment Setup
Create a .env file with your configuration:
The database URL can point to SQLite for local development or PostgreSQL for production.
Creating Your First Agent
Here's the basic agent implementation:
The Agent.create() method takes three core parameters: a name for identification, the LLM model to use, and a system prompt that defines the agent's behavior and personality.
Working with Tasks
Tasks provide structure for agent interactions. Create a task with a prompt, then execute it:
The createTask() method generates a task object with an ID and status. The executeTask() method processes the task and returns the agent's response.
Running Your Agent
If you cloned the repository:
For a standalone script:
Core API Methods
Astreus provides three essential methods for basic agent operations:
Agent.create()- Creates a new agent instance with configurationagent.createTask()- Generates a task with a prompt and optional metadataagent.executeTask()- Executes a task by ID and returns the response
These methods form the foundation for building more complex agent systems.
Complete Example
Here's everything together:
This creates an agent, assigns it a task, and logs the response. The agent uses GPT-4 to process the prompt and generate an answer.
What's Next
This is just the beginning. The Astreus framework supports more advanced features like memory, knowledge bases, vision capabilities, and multi-agent systems. Start with this foundation and expand as your needs grow.
Source Code
The complete working example is available on GitHub: astreus-ai/your-first-agent
This experiment is written for Astreus v0.5.37. Please ensure you are using a compatible version.
Keep reading
- Building Agents with Memory in Astreus
Learn how to build AI agents with persistent memory using Astreus. Store conversation history and retrieve context across sessions.
- Building Agents with Knowledge in Astreus
Create AI agents that can search and retrieve information from knowledge bases using RAG. Learn how to integrate documents, enable semantic search, and build domain-specific agents.
- Building Basic Sub-Agents in Astreus
Learn how to create and coordinate multiple AI agents using Astreus. Build specialized agents that work together under a coordinator for complex task delegation.