This guide takes you from zero to a running AutoGPT agent in under 5 minutes, using the Gemini provider and the ArchitectGPT built-in agent.
- Rust 1.89+ (
rustup update stable). - A Gemini API key.
export GEMINI_API_KEY=<your_gemini_api_key>cargo new my-agent && cd my-agentAdd AutoGPT to Cargo.toml:
[dependencies]
autogpt = { version = "0.4.5", features = ["gem", "gpt"] }
tokio = { version = "1", features = ["full"] }Replace src/main.rs with:
use autogpt::prelude::*;
#[tokio::main]
async fn main() {
let persona = "Lead UX/UI Designer";
let behavior = r#"Generate a diagram for a simple web application running on Kubernetes.
It consists of a single Deployment with 2 replicas, a Service to expose the Deployment,
and an Ingress to route external traffic. Also include a basic monitoring setup
with Prometheus and Grafana."#;
let agent = ArchitectGPT::new(persona, behavior).await;
let autogpt = AutoGPT::default()
.with(agents![agent])
.build()
.expect("Failed to build AutoGPT");
match autogpt.run().await {
Ok(response) => println!("{}", response),
Err(err) => eprintln!("Agent error: {:?}", err),
}
}cargo runAutoGPT calls Gemini, generates Python diagrams-library code, and writes it to:
workspace/architect/diagram.py
./workspace/architect/.venv/bin/python ./workspace/architect/diagram.pyA PNG architecture diagram appears in workspace/architect/.
💡 Tip
To switch to OpenAI instead of Gemini, set
export AI_PROVIDER=openai and export OPENAI_API_KEY=..., then change the feature flag to features = ["oai", "gpt"].
The agents! macro accepts any number of agents. AutoGPT runs them concurrently using Tokio tasks:
use autogpt::prelude::*;
#[tokio::main]
async fn main() {
let architect = ArchitectGPT::new(
"Software Architect",
"Design a microservices architecture for an e-commerce platform.",
).await;
let backend = BackendGPT::new(
"Backend Developer",
"Generate a REST API for user authentication in Rust using axum.",
"rust",
).await;
let autogpt = AutoGPT::default()
.with(agents![architect, backend])
.build()
.expect("Failed to build AutoGPT");
match autogpt.run().await {
Ok(msg) => println!("{}", msg),
Err(e) => eprintln!("{:?}", e),
}
}Both agents execute concurrently and their outputs land in their respective workspace directories.
- Configuration →: set up memory, email, and image generation.
- Custom Agents →: build agents tailored to your domain.
- Interactive Mode →: chat with AutoGPT from the terminal.