Installation

Install the PraisonAI Rust SDK in your project

Get started with PraisonAI in Rust in under a minute.

Diagram

Setup

📦 Install

⚙️ Configure

🚀 Run

Quick Start

  1. Add to Cargo.toml
    toml
    [dependencies]
    praisonai = "0.1"
    tokio = { version = "1", features = ["full"] }
  2. Set API Key
    bash
    export OPENAI_API_KEY="your-key"
  3. Create Your First Agent
    rust
    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("Hello!").await?;
        println!("{}", response);
    
        Ok(())
    }
  4. Run
    bash
    cargo run

Requirements

RequirementVersion
Rust1.70+
Tokio1.x

Optional Features

Enable additional capabilities in Cargo.toml:

toml
[dependencies]
praisonai = { version = "0.1", features = ["mcp", "knowledge"] }
FeatureDescription
mcpModel Context Protocol support
knowledgeRAG and knowledge base
fullAll features enabled

Best Practices

Use environment variables for API keys

Never hardcode API keys in your code. Use environment variables.

Start with minimal features

Add features incrementally as needed for smaller binary size.


Related