> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pryveo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Reference

<Note>
  **NEW!** Pryveo now includes a comprehensive [Shared Memory API](/shared-memory) that provides access to centralized user data like calendar, files, browsing history, contacts, and more—all with fine-grained permissions.
</Note>

## Installation

Add the SDK and ensure your crate is built as a WASM module.

```toml theme={null}
[dependencies]
pryveo-sdk = { path = "../pryveo-sdk" }

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

## Core APIs

### Logging

```rust theme={null}
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)

```rust theme={null}
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)

```rust theme={null}
use pryveo_sdk::storage::{read, write};

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

### Clipboard

```rust theme={null}
use pryveo_sdk::clipboard::{read_text, write_text};

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

write_text("Hello from Pryveo!")?;
```

### Vector Database and Embeddings

```rust theme={null}
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.

```rust theme={null}
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(())
}
```
