Quick Start

Create your first AI agent in 5 minutes

Build your first AI agent in under 5 minutes.

Diagram

Your First Agent

👨‍💻 Create

🚀 Run

✨ Success

Your First Agent

  1. Create the Project
    bash
    cargo new my-agent
    cd my-agent
  2. Add Dependencies
    toml
    # Cargo.toml
    [dependencies]
    praisonai = "0.1"
    tokio = { version = "1", features = ["full"] }
  3. Set API Key
    bash
    export OPENAI_API_KEY="your-key"
  4. 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(())
    }
  5. Run It
    bash
    cargo run

    Output:

    Rust is a systems programming language focused on safety, 
    concurrency, and performance...

Add a Tool

Give your agent abilities with tools:

rust
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(())
}

What’s Next?