Rust SDK
Async Rust client for Trefur Observe. Pairs naturally with rig-core and the wider Tokio ecosystem.
Install
cargo add trefur-observeHello, world
use trefur_observe::{Client, AgentRun, AgentStep};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder()
.api_key(std::env::var("TREFUR_API_KEY")?)
.build()?;
let mut run = AgentRun::new("custom", "rust-hello", "completed");
run.steps.push(AgentStep::tool_use("search"));
client.record(run).await;
// Flush + stop the background timer before the process exits so a short
// program's first trace lands right away. shutdown() flushes internally.
client.shutdown().await;
Ok(())
}Telemetry is buffered and shipped on a periodic flush. Because a short program can exit before that timer fires, always client.shutdown().await (or client.flush().await) before returning. Note the ? operator can early-return on an error before your flush — flush on those paths too (or drop the flush into a guard) so telemetry from a failed run isn't lost.
Builder options
.api_key(...)— required,trf_obs_*.endpoint(...)— defaults tohttps://observe.trefur.com.batch_size(...)— defaults to10
Recording steps
let mut run = AgentRun::new("custom", "search-bot", "completed");
run.steps.push(AgentStep::llm_call("claude-sonnet-4-5"));
run.steps.push(AgentStep::tool_use("search"));
client.record(run).await;
client.flush().await?;Environment variables
Canonical list: env-vars reference.
Source + tests live in trefur-ai/trefur-sdks under rust/observe-rust. License: Apache 2.0.