Platform
ScaiWave ScaiGrid ScaiCore ScaiBot ScaiDrive ScaiKey Models Tools & Services
Solutions
Organisations Developers Internet Service Providers Managed Service Providers AI-in-a-Box
Resources
Support Documentation Blog Downloads
Company
About Research Careers Investment Opportunities Contact
Log in

Rust SDK

Async Rust client on tokio and reqwest, with rustls (no OpenSSL). It covers the same domains as the Python, JavaScript and .NET SDKs, plus a strongly typed client for the signing engine.

Install#

The crate is published at https://www.scailabs.ai/downloads under "ScaiVault SDKs", not on crates.io. Unpack it into your project and depend on it by path:

bash
1
2
mkdir -p vendor
tar -xzf scaivault-sdk-1.10.0.crate -C vendor
toml
1
2
3
[dependencies]
scaivault-sdk = { path = "vendor/scaivault-sdk-1.10.0" }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Rust 1.75+. Latest release: 1.10.0. Apache-2.0.

Authenticate#

rust
1
2
3
4
5
6
use scaivault_sdk::Client;

let sv = Client::new(
    "https://scaivault.scailabs.ai",
    std::env::var("SCAIVAULT_API_KEY")?,
)?;

The client sends a service-account API key as X-API-Key on every request. ScaiKey JWTs are not supported. Client is cheap to clone; share one per process.

The default client never follows redirects (a 3xx comes back as Error::Api, so the key is never re-sent elsewhere), only talks https://, and times out after 10 s to connect and 30 s per request. To change that, pass your own reqwest::Client to Client::with_http — and keep redirects off on it.

Signing#

rust
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use scaivault_sdk::{Client, Suite};

let signing = sv.signing();

// Create a key (sign:create)
let key = signing
    .create_key("sign/acme/release-manifest", Suite::Ed25519, Some("Release manifests"))
    .await?;

// Settings fixed at creation: per-key rate limit, description, HSM binding.
// They can't be changed later. Over the limit, sign returns 429 with Retry-After.
use scaivault_sdk::CreateKeyOptions;
let capped = signing
    .create_key_with(
        "sign/acme/release-root",
        Suite::MlDsa65,
        &CreateKeyOptions { rate_limit_per_min: Some(10), ..Default::default() },
    )
    .await?;

// Sign and verify (sign:use / sign:read)
let sig = signing.sign(&key.path, b"release v2.4.0", false).await?;
let check = signing.verify(&key.path, b"release v2.4.0", &sig, None, false).await?;
assert!(check.valid);

// Batch-sign up to 100 messages
let batch: Vec<&[u8]> = vec![b"node-1", b"node-2"];
let sigs = signing.batch_sign(&key.path, &batch, false).await?;

// Public key for verifying elsewhere (raw bytes; SPKI DER for P-384)
let pk = signing.public_key(&key.path, None).await?;

// ECDSA P-384 over a precomputed 48-byte SHA-384 digest
// signing.sign("sign/acme/release-p384", &digest, true).await?;

// Lifecycle: rotate/disable/enable need sign:manage; destroy needs sign:destroy
signing.rotate(&key.path).await?;    // old versions still verify
signing.disable(&key.path).await?;
signing.enable(&key.path).await?;
signing.destroy(&key.path).await?;   // permanent
let keys = signing.list().await?;

Suites: Suite::Ed25519 (s3-ed25519), Suite::EcdsaP384 (s2-ecdsa-p384), Suite::MlDsa65 (s4-mldsa65). Messages, signatures and public keys are plain bytes; base64 on the wire is handled for you.

Other domains#

Every other domain returns serde_json::Value and takes JSON bodies, so it works with any endpoint shape without waiting for a typed model:

rust
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
use serde_json::json;

let secret = sv.secrets().read("app/database/credentials").await?;
println!("{}", secret["data"]["password"]);

sv.secrets()
    .write("app/api-key", &json!({"data": {"key": "sk-live-…"}}))
    .await?;

let certs = sv.pki().list_certificates(&[("limit", "10")]).await?;
let me = sv.whoami().await?;

List methods take query parameters as &[(&str, &str)]; pass &[] for none. Values should already be URL-safe.

Error handling#

rust
1
2
3
4
5
6
7
8
use scaivault_sdk::Error;

match sv.signing().sign("sign/acme/unknown", b"x", false).await {
    Ok(sig) => println!("{} bytes", sig.len()),
    Err(Error::Api { status: 404, message }) => eprintln!("no such key: {message}"),
    Err(Error::Api { status: 429, .. }) => eprintln!("rate limited; retry later"),
    Err(e) => return Err(e.into()),
}
Variant Meaning
Error::Api { status, message } Non-2xx response, including a 3xx (redirects are never followed); message is the response body
Error::Transport Network or TLS failure
Error::Json / Error::Base64 A response that couldn't be decoded

The client does not retry. Wrap calls in your own retry for 429 and 5xx, honouring Retry-After.

What's covered#

signing() (typed), plus secrets(), batch(), policies(), secret_policies(), service_accounts(), audit(), rotation(), pki(), acme(), dynamic(), federation(), identity(), subscriptions(), webhooks(), and health() / whoami() on the client.

What's next#

Updated 2026-11-10 22:08:42 View source (.md) rev 3