sovereign-router — async Rust client for the Sovereign Frontier AIEM
registry and SovereignRouter inference gateway. Built on reqwest +
tokio; every chat response carries a cryptographically-attested
provenance envelope.
Append a message with the given role. Call multiple times to build a conversation.
builder.max_tokens(n: u32) → ChatBuilder
builder.temperature(t: f32) → ChatBuilder
builder.policy(p) → ChatBuilder
Override the client-level default policy for this request.
builder.provider(p) → ChatBuilder
Pin to a specific provider ID, bypassing the router's selection logic.
builder.send().await → Result<ChatResponse>
Execute the non-streaming request. Returns a ChatResponse including attestation.
example — multi-turn
let resp = sr.chat()
.model("qwen/qwen3-235b-a22b")
.system("Reply concisely.")
.user("What is 2+2?")
.assistant("4.")
.user("Multiply that by 3.")
.max_tokens(64)
.send().await?;
println!("{}", resp.choices[0].message.content);
Returns an async Stream of StreamEvent items. Consume with
futures_util::StreamExt::next() or while let.
The final events are always Finish → Attestation → Done.
rust — streaming example
use futures_util::StreamExt;
use sovereign_router::StreamEvent;
let mut stream = sr.chat()
.model("qwen/qwen3-235b-a22b")
.user("Count to 10.")
.stream().await?;
while letSome(event) = stream.next().await {
match event? {
StreamEvent::Delta(text) => print!("{text}"),
StreamEvent::Attestation(att) => {
println!("\nrekor_index: {}", att.rekor_index);
}
StreamEvent::Done => break,
_ => {}
}
}
All async methods return anyhow::Result<T>. HTTP errors are
surfaced as anyhow::Error with the status code and response body in
the message. Use anyhow::Context to add context.
example
use anyhow::Context;
let resp = sr.chat()
.model("nonexistent/model")
.user("hello")
.send().await
.context("chat completion failed")?;
Feature flags
default features: rustls-tls
TLS via rustls. No OpenSSL dependency — safe for static/musl builds.
To use native OpenSSL instead, disable default features and enable
native-tls:
Cargo.toml
sovereign-router = { version = "0.1", default-features = false, features = ["native-tls"] }