Thalovant Rust SDK
Rust SDK for connecting services, CLIs, devices, and agents to Thalovant hubs.
The control API is used to discover hubs and provision a client identity. After that, the SDK talks directly to the hub data plane over HTTPS, WSS, or MQTTS.
Full docs: https://docs.thalovant.com/developers/sdks/rust/
What You Need
- A Thalovant account with API access for authenticated control-plane actions.
- A hub id or slug.
- A client identity for that hub. You can create one through the API or use one downloaded from the dashboard.
Install
Quick Start
use ;
async
ControlPlane::default() uses https://api.thalovant.com. Use
ControlPlane::new(...) only for local development or a self-hosted control plane.
Keep result.identity secret. It contains the client credentials used by the
hub. Do not log result.as_value(true).
List Your Hubs
Authenticated accounts can list owned or visible hubs:
let mut control = default;
control.login.await?;
let page = control.list_hubs.await?;
if let Some = page.get.and_then
Use An Existing Identity
For local development, store one or more identities in the protected SDK config:
profile: prod
profiles:
prod:
identity:
access_key: ...
password: ...
site_id: demo-agent
default_master: https://jokes.thalovant.io
data_plane_endpoints:
wss: wss://jokes.thalovant.io/public
https: https://jokes.thalovant.io/public
mqtt: mqtts://mqtt.thalovant.com:8883
mqtt:
endpoint: mqtts://mqtt.thalovant.com:8883
username: ...
password: ...
topic_prefix: hubs/hub-id/clients/client-id
tls: true
use ;
let client = from_config?;
let reply = client
.ask
.await?;
println!;
client.close.await?;
SDKs reject config files that are readable or writable by other users on Linux and macOS. Keep this file out of git.
Raw identity files are supported too:
let client = from_file?;
Environment variables are supported too:
let client = from_env?;
Protocols
Hubs may expose one or more public data-plane protocols:
wss: secure realtime WebSocket, the default public path and SDK preference.https: request/response HTTP protocol exposed as HTTPS.mqtt: broker-mediated MQTT over TLS. Requires per-client broker credentials.
Inspect what an identity supports:
let identity = result.identity.clone;
println!;
println!;
println!;
println!;
println!;
Connect with a specific protocol:
for protocol in
MQTT identities include a broker endpoint, username, password, TLS flag, and
topic prefix. The broker credentials are scoped to that client and should be
treated like a password. Public identities should use mqtts://; the SDK also
honors an explicit tls: true flag from the identity.
Conversations
Use a conversation when related turns should share one session.
use ;
let conversation = client.conversation;
let first = conversation
.ask
.await?;
let second = conversation
.ask
.await?;
println!;
println!;
Client Context
Context lets skills know which app, device, user, or channel made the request.
use ;
let context = build_client_context;
let reply = client
.ask
.await?;
Actions And Exact Inputs
Use actions for button payloads and codes for exact typed or scanned values.
use ;
let conversation = client.conversation;
conversation
.send_action
.await?;
conversation
.send_code
.await?;
Rich Responses
Replies can include text, choices, tables, images, or attachments.
let items = reply.display_items;
for item in items
Common Issues
missing access token: callcontrol.login(...)before private control-plane actions, or pass an access token toControlPlane::new.API access requires a paid plan: upgrade the workspace before using the SDK control-plane API to provision private resources.UnsupportedProtocol: the hub does not expose that protocol, or the identity was created before that protocol was enabled.- MQTT fails immediately: create or download a fresh client identity after MQTT
is enabled. MQTT needs the per-client
identity.mqttcredentials. - A request times out: set
RequestOptions { timeout: Some(...), .. }.
API Shape
ControlPlane::default()ControlPlane::new(api_url, access_token)for local or self-hosted control planescontrol.login(email, password, scope)control.list_public_hubs(limit, cursor)control.get_public_hub(hub_ref)control.list_hubs(limit, cursor, owner_id)control.get_hub(hub_id)control.create_client_identity_for_hub_id(hub_id, options)Identity::from_config(profile)Client::from_config(profile)Identity::from_file(path)Client::from_file(path)Client::from_env()Client::with_protocol(identity, protocol)client.ask(text, options)client.send_utterance(text, options)client.send_action(payload, options)client.send_code(value, options)client.conversation(options)
Development