llmrix-rust-sdk
Official Rust SDK for llmrix — AI Agent Platform.
- Rust 1.75+ (MSRV)
- Async/await with
tokioruntime - SSE streaming via
reqwest+futures-util - Fully typed with
serdeserialization thiserror-based error hierarchy
Installation
Add to your Cargo.toml:
[]
= "1.0"
= { = "1", = ["full"] }
Quick Start
use ;
async
API Reference
LlmrixClient
builder
.base_url // required
.api_key // optional
.timeout // optional, default 60 s
.build?
LlmrixClient is Clone and cheap to clone — the inner reqwest::Client
shares its connection pool across all clones.
ConversationsResource
Obtained via client.conversations().
| Method | Returns | Description |
|---|---|---|
create(req).await |
Result<Conversation> |
Create a new conversation |
list(last_id, size).await |
Result<PageResult<Conversation>> |
Cursor-paginated list |
get(id).await |
Result<Conversation> |
Fetch a single conversation |
update(id, req).await |
Result<Conversation> |
Update title / agent |
delete(id).await |
Result<()> |
Permanently delete |
messages(id, last_id, size).await |
Result<PageResult<Message>> |
Paginated message history |
Cursor pagination:
let mut page = client.conversations.list.await?;
while page.has_more
ChatResource
Obtained via client.chat(conv_id).
| Method | Returns | Description |
|---|---|---|
send(message, handler).await |
Result<()> |
Stream a plain-text message |
send_request(req, handler).await |
Result<()> |
Stream a full ChatRequest |
stop().await |
Result<()> |
Cancel the current run |
decide(decisions).await |
Result<()> |
Submit HITL decisions |
Stream handler
type StreamHandler =
Returning Err(...) from the handler aborts the stream.
Stream Event Types
use StreamEvent;
client.chat.send.await?;
| Variant | Channel | Description |
|---|---|---|
RunStart |
lifecycle |
Agent run started |
RunEnd |
lifecycle |
Agent run completed |
MessageChunk |
messages |
Incremental text chunk |
ToolStart |
tools |
Tool invocation started |
ToolEnd |
tools |
Tool invocation finished |
SubagentStart |
tools |
Sub-agent spawned |
SubagentEnd |
tools |
Sub-agent finished |
HitlInterrupt |
hitl |
Human approval required |
Error |
error |
Run failed with error |
Cancelled |
error |
Run was cancelled |
Heartbeat |
heartbeat |
Keep-alive (silently dropped) |
Error Handling
use ;
match client.conversations.get.await
| Variant | When |
|---|---|
LlmrixError::Api |
Non-2xx HTTP response; has status and body |
LlmrixError::Auth |
HTTP 401 / 403 |
LlmrixError::Http |
Network-level reqwest error |
LlmrixError::Sse |
Unrecoverable SSE parse error |
Advanced Usage
HITL (Human-in-the-Loop)
use HitlDecision;
let chat = client.chat;
chat.send.await?;
Collecting the full response
async
Building from Source
Generate documentation:
Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
License
Apache License 2.0 — see the LICENSE file.