wauldo 0.1.0

Official Rust SDK for Wauldo — Verified AI answers from your documents
Documentation

Wauldo Rust SDK

Crates.io Downloads Rust License: MIT

Verified AI answers from your documents. Every response includes source citations, confidence scores, and an audit trail — or we don't answer at all.

Official Rust SDK for the Wauldo API — the AI inference layer with smart model routing and zero hallucinations.

Why Wauldo?

  • Zero hallucinations — every answer is verified against source documents
  • Smart model routing — auto-selects the cheapest model that meets quality (save 40-80% on AI costs)
  • One API, 7+ providers — OpenAI, Anthropic, Google, Qwen, Meta, Mistral, DeepSeek with automatic fallback
  • OpenAI-compatible — swap your base_url, keep your existing code
  • Full audit trail — confidence score, grounded status, model used, latency on every response

Quick Start

use wauldo::{HttpClient, HttpConfig, ChatRequest, ChatMessage, Result};

#[tokio::main]
async fn main() -> Result<()> {
    let client = HttpClient::new(
        HttpConfig::new("https://api.wauldo.com").with_api_key("YOUR_API_KEY"),
    )?;

    let req = ChatRequest::new("auto", vec![ChatMessage::user("What is Rust?")]);
    let resp = client.chat(req).await?;
    println!("{}", resp.text().unwrap_or(""));
    Ok(())
}

Installation

[dependencies]
wauldo = "0.1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Requirements: Rust 1.70+

Features

Chat Completions

let req = ChatRequest::new("auto", vec![
    ChatMessage::system("You are a helpful assistant."),
    ChatMessage::user("Explain ownership in Rust"),
]);
let resp = client.chat(req).await?;
println!("{}", resp.text().unwrap_or(""));

RAG — Upload & Query

// Upload a document
let upload = client.rag_upload("Contract text here...", Some("contract.txt".into())).await?;
println!("Indexed {} chunks", upload.chunks_count);

// Query with verified answer
let result = client.rag_query("What are the payment terms?", None).await?;
println!("Answer: {}", result.answer);
println!("Confidence: {:.0}%", result.confidence() * 100.0);
println!("Grounded: {}", result.grounded());
for source in &result.sources {
    println!("  Source ({}%): {}", (source.score * 100.0) as u32, source.content);
}

Streaming (SSE)

let req = ChatRequest::new("auto", vec![ChatMessage::user("Hello!")]);
let mut rx = client.chat_stream(req).await?;
while let Some(chunk) = rx.recv().await {
    print!("{}", chunk.unwrap_or_default());
}

Conversation Helper

let mut conv = client.conversation()
    .with_system("You are an expert on Rust programming.")
    .with_model("auto");
let reply = conv.say("What is the borrow checker?").await?;
let follow_up = conv.say("Give me an example").await?;

Error Handling

use wauldo::Error;

match client.chat(req).await {
    Ok(resp) => println!("{}", resp.text().unwrap_or("")),
    Err(Error::Server { code, message, .. }) => eprintln!("Server error [{}]: {}", code, message),
    Err(Error::Connection(msg)) => eprintln!("Connection failed: {}", msg),
    Err(Error::Timeout(msg)) => eprintln!("Timeout: {}", msg),
    Err(e) => eprintln!("Other error: {}", e),
}

RapidAPI

let config = HttpConfig::new("https://api.wauldo.com")
    .with_header("X-RapidAPI-Key", "YOUR_RAPIDAPI_KEY")
    .with_header("X-RapidAPI-Host", "smart-rag-api.p.rapidapi.com");
let client = HttpClient::new(config)?;

Get your free API key (300 req/month): RapidAPI

Links

Contributing

Found a bug? Have a feature request? Open an issue.

License

MIT — see LICENSE