Skip to content
  • Follow System
  • English
  • 中文

Rust SDK Quickstart

picora-sdk is the official Rust client for the Picora API. It is a PC-focused subset, not full API coverage: it ships exactly what desktop consumers (the Moraya Tauri app) need — knowledge bases, document revisions, user settings — plus the shared HTTP / auth / error core. It grows toward fuller parity as consumers need it.

Install

The crate is consumed as a git-tag dependency (not yet published to crates.io):

[dependencies]
picora-sdk = { git = "https://github.com/zouwei/picora-sdk", tag = "rust-v0.1.0" }

It’s part of the multi-language zouwei/picora-sdk repo (alongside sdk-nodejs / sdk-python); the Rust crate lives in sdk-rust/ and releases on rust-v* tags.

First call (API Key)

// Construct with a base URL + API key (sk_live_… from center.picora.me/integration).
// Use https://api.picora.cn for the China deployment.
let client = picora_sdk::PicoraClient::new("https://api.picora.me", "sk_live_…")?;
// Typed resource methods
let kbs = client.kb_list().await?;
let manifest = client.kb_manifest(&kbs[0].id).await?;
let revisions = client.doc_revisions(doc_id).await?;

Low-level escape hatch

Any endpoint outside the typed surface goes through the same auth + error pipeline:

let usage: serde_json::Value =
client.http().send_json(client.get("/v1/user/me/usage"), "usage").await?;

Error model

Every method returns Result<_, PicoraError>. PicoraError’s Display is a sanitized, user-facing message — it never leaks bearer tokens, sk_live_ prefixes, or raw response bodies. That makes a Tauri command migrate with a plain .map_err(|e| e.to_string()):

#[tauri::command]
async fn list_kbs(client: tauri::State<'_, picora_sdk::PicoraClient>) -> Result<_, String> {
client.kb_list().await.map_err(|e| e.to_string())
}

Releasing

Push a rust-v* git tag matching Cargo.toml’s version; the publish-rust.yml workflow builds, tests, packages, and creates a GitHub Release with the .crate artifact. (No crates.io publish yet — consumers pin the git tag.)