Quick setup examples

Rust (HTTP) Quickstart

Call the Unison brain from Rust using reqwest and serde_json — async, minimal boilerplate.

Add the dependencies to Cargo.toml, then use the async reqwest client. All requests carry your token read from the environment.

Prerequisites

export UNISON_TOKEN=usk_live_...
# Cargo.toml
[dependencies]
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }

Recall — fetch prompt-ready context

use reqwest::Client;
use serde::Deserialize;
use std::env;

#[derive(Deserialize)]
struct ContextResponse {
    #[serde(rename = "weakEvidence")]
    weak_evidence: bool,
    #[serde(rename = "contextMd")]
    context_md: String,
}

async fn recall(query: &str) -> Result<String, reqwest::Error> {
    let token = env::var("UNISON_TOKEN").expect("UNISON_TOKEN not set");
    let client = Client::new();

    let resp: ContextResponse = client
        .get("https://brain.unisonlabs.ai/v1/brain/context")
        .bearer_auth(&token)
        .query(&[("q", query), ("k", "5"), ("mode", "auto")])
        .send()
        .await?
        .json()
        .await?;

    if resp.weak_evidence {
        Ok(String::new())
    } else {
        Ok(resp.context_md)
    }
}

#[tokio::main]
async fn main() {
    let memory = recall("payment service architecture").await.unwrap();
    println!("{}", memory);
}

Persist — save a conversation to the brain

use reqwest::Client;
use serde_json::json;
use std::env;

async fn persist() -> Result<(), reqwest::Error> {
    let token = env::var("UNISON_TOKEN").expect("UNISON_TOKEN not set");
    let client = Client::new();

    let body = json!({
        "dump": {
            "turns": [
                { "role": "user",      "content": "What queue library should we use?" },
                { "role": "assistant", "content": "Switched to pgmq — simpler ops than Redis." }
            ]
        },
        "sourceRef": "session-1"
    });

    let resp: serde_json::Value = client
        .post("https://brain.unisonlabs.ai/v1/brain/remember")
        .bearer_auth(&token)
        .json(&body)
        .send()
        .await?
        .json()
        .await?;

    println!("jobId: {}", resp["jobId"]);
    Ok(())
}

remember runs the save-or-skip curation pipeline (dedupe, curated notes, entity facts) as a background job — poll GET /v1/brain/jobs/{jobId} for status. To write a document directly instead, POST a { type: "document", content, ... } item to /v1/brain/ingest — see Ingest.

On this page