AxonFlow SDK for Rust
Enterprise-grade Rust SDK for the AxonFlow AI governance platform. Add invisible AI governance to your applications with production-ready features including retry logic, caching, fail-open strategy, and debug mode.
How This SDK Fits with AxonFlow
This SDK is a client library for interacting with a running AxonFlow control plane. It is used from application or agent code to send execution context, policies, and requests at runtime.
A deployed AxonFlow platform (self-hosted or cloud) is required for end-to-end AI governance. SDKs alone are not sufficient—the platform and SDKs are designed to be used together.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1", = ["full"] }
Quick Start
Basic Usage (Invisible Governance via Interceptor)
The most common way to use AxonFlow is via an Interceptor. This wraps your existing LLM client (e.g., an OpenAI-compatible client) and automatically applies governance to every call.
use ;
use ;
async
Manual Audit (Gateway Mode)
If you are making LLM calls directly and just want to log them for compliance and cost tracking:
use ;
let axon = new?;
// After your direct LLM call
axon.audit_llm_call.await?;
Examples
The SDK includes several runnable examples demonstrating common integration patterns. You can find them in the examples/ directory.
Running the Examples
Before running the examples, set your AxonFlow credentials as environment variables:
# Optional: defaults to http://localhost:8080
Then use cargo run --example <name> to execute an example:
- Basic Chat Governance:
- Model Context Protocol (MCP) Connectors:
- Multi-Agent Planning (MAP):
- Invisible Governance (Interceptors):
Advanced Features
Fail-Open Strategy
In Production mode, if the AxonFlow platform is unreachable, the SDK will "fail-open." This ensures your application remains available even if the governance layer is degraded.
Caching
The SDK includes a built-in async cache (powered by moka) with TTL support to reduce latency for redundant requests. Caching is automatically disabled for mutation operations like plan execution.
MCP & MAP Support
The Rust SDK provides full parity for Model Context Protocol (MCP) and Multi-Agent Planning (MAP):
- MCP: List, install, and query Model Context connectors with full policy enforcement.
- MAP: Generate and execute complex multi-agent plans programmatically.
Configuration
let config = AxonFlowConfig ;
Telemetry
The SDK includes a non-blocking background heartbeat that follows the AxonFlow telemetry contract: at most one anonymous ping per machine every 7 days. This is used for licensing compliance and platform health monitoring.
License
This project is licensed under the MIT License - see the LICENSE file for details.