Skip to main content

Installation

Add the SDK and ensure your crate is built as a WASM module.
[dependencies]
pryveo-sdk = { path = "../pryveo-sdk" }

[lib]
crate-type = ["cdylib"]

Core APIs

Logging

use pryveo_sdk::logging::{log, LogLevel};

log(LogLevel::Info, "App started")?;
log(LogLevel::Warn, "This is a warning")?;
log(LogLevel::Error, "Something went wrong")?;

Inference (LLM)

use pryveo_sdk::inference::{GenerateRequest, generate};

let response = generate(GenerateRequest {
    prompt: "What is Rust?".to_string(),
    max_tokens: Some(100),
    temperature: Some(0.7),
    top_p: Some(0.9),
})?;

println!("AI says: {}", response.text);

Storage (Key-Value)

use pryveo_sdk::storage::{read, write};

write("user_name", "Alice".as_bytes())?;
let data = read("user_name")?;
let name = String::from_utf8(data)?;

Clipboard

use pryveo_sdk::clipboard::{read_text, write_text};

let text = read_text()?;
println!("Clipboard: {}", text);

write_text("Hello from Pryveo!")?;

Vector Database and Embeddings

use pryveo_sdk::vector::{index_document, search, rag_query};
use std::collections::HashMap;

let mut metadata = HashMap::new();
metadata.insert("title".to_string(), "My Document".to_string());

index_document(
    "doc_123",
    "This is the document content to index.",
    metadata
)?;

let results = search("find similar content", 5)?;
for result in results {
    println!("Score: {:.2}, Doc: {}", result.similarity, result.document.id);
}

let context = rag_query("What is this document about?", 500)?;
println!("Retrieved context: {}", context);

App Entry Point

Every Pryveo app must export a run function.
use pryveo_sdk::prelude::*;

#[no_mangle]
pub extern "C" fn run() -> i32 {
    match main_app() {
        Ok(_) => {
            logging::log(logging::LogLevel::Info, "Success!").ok();
            0
        }
        Err(e) => {
            logging::log(logging::LogLevel::Error, &format!("Error: {}", e)).ok();
            1
        }
    }
}

fn main_app() -> pryveo_sdk::Result<()> {
    logging::log(logging::LogLevel::Info, "Hello, Pryveo!")?;
    Ok(())
}