Quick Start
Create your first AI agent in 5 minutes
Build your first AI agent in under 5 minutes.
Your First Agent
- Create the Project
bash cargo new my-agent cd my-agent - Add Dependencies
toml # Cargo.toml [dependencies] praisonai = "0.1" tokio = { version = "1", features = ["full"] } - Set API Key
bash export OPENAI_API_KEY="your-key" - Write the Code
rust // src/main.rs use praisonai::Agent; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let agent = Agent::new() .name("Assistant") .instructions("You are a helpful assistant") .build()?; let response = agent.chat("What is Rust?").await?; println!("{}", response); Ok(()) } - Run It
bash cargo runOutput:
Rust is a systems programming language focused on safety, concurrency, and performance...
Add a Tool
Give your agent abilities with tools:
use praisonai::{Agent, tool};
#[tool]
fn get_weather(city: String) -> String {
format!("Weather in {}: Sunny, 72°F", city)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let agent = Agent::new()
.name("Weather Bot")
.instructions("Help with weather queries")
.tool(get_weather)
.build()?;
agent.chat("What's the weather in Tokyo?").await?;
// Agent calls get_weather("Tokyo") automatically
Ok(())
}