-
Notifications
You must be signed in to change notification settings - Fork 1
SDK API Reference
Crate: atp-sdk | Tests: 28 (13 unit + 15 doc-tests)
The SDK provides a dead-simple facade over the entire ATP protocol stack. Two flavors: verb functions (print) and noun functions (return typed values).
- Zero ceremony: No structs to create, no config to pass, no setup required
- Global network: A 50-agent network is lazily initialized on first use
- Two flavors: Verb functions print, noun functions return
-
Display on everything: Every return type implements
Display -
String-based tasks: Just pass
"coding"— no enum imports needed
These functions print results directly to stdout. Perfect for exploration, demos, and quick checks.
pub fn benchmark()Prints the full 7-scenario benchmark table (50 agents, 10,000 tasks).
Output:
════════════════════════════════════════════
ATP Benchmark: 50 agents, 10000 tasks, seed=42
════════════════════════════════════════════
Scenario Cost/Task Latency Quality ...
──────────────────────────────────────────────────
Sequential $0.0844 800ms 0.837 ...
ATP (full) $0.0393 568ms 0.904 ...
...
pub fn route(skill: &str)Prints the best route for the given task type.
Example: atp_sdk::route("coding");
Output: Route: draft_refine via 2 agents (q=0.92, $0.0500, 45ms)
pub fn compress(data: &[u8], skill: &str)Prints context compression statistics.
Example: atp_sdk::compress(b"context data...", "analysis");
Output: 28.3x compression (50000B → 1768B, 3 chunks, confidence=0.85)
pub fn sign(message: &[u8])Creates a new agent, signs the message, verifies, and prints everything.
Example: atp_sdk::sign(b"hello");
Output:
Agent: did:key:z6Mk...
Signature: a3f2b1c9...
Verified: true
pub fn trust(skill: &str)Prints the average trust score for the given task type.
Example: atp_sdk::trust("coding");
Output: Trust: 0.87 (n=42)
These return typed results for use in production code and pipelines.
pub fn bench(tasks: usize) -> BenchReportRuns the benchmark and returns a structured report.
let report = atp_sdk::bench(10_000);
let atp = report.atp().unwrap();
println!("Cost: ${:.4}", atp.avg_cost_per_task);
println!("Quality: {:.3}", atp.avg_quality);
// Access any scenario
let seq = report.scenario("sequential").unwrap();
// Iterate all
for s in report.all() {
println!("{}: ${:.4}", s.scenario, s.avg_cost_per_task);
}
// Pretty print (uses Display)
println!("{report}");pub fn find_route(skill: &str) -> RouteResult
pub fn find_route_with(skill: &str, min_quality: f64) -> RouteResultlet route = atp_sdk::find_route("coding");
println!("Pattern: {}", route.pattern); // "draft_refine"
println!("Agents: {}", route.agents); // 2
println!("Quality: {:.2}", route.quality); // 0.92
println!("Cost: ${:.4}", route.cost); // 0.0500
println!("Latency: {}ms", route.latency_ms); // 45
// With minimum quality constraint
let route = atp_sdk::find_route_with("coding", 0.95);pub fn shrink(data: &[u8], skill: &str) -> CompressResultlet comp = atp_sdk::shrink(b"context data...", "analysis");
println!("Ratio: {}x", comp.ratio); // 28.3
println!("Original: {}B", comp.original_size); // 50000
println!("Compressed: {}B", comp.compressed_size); // 1768
println!("Chunks: {}", comp.chunks); // 3
println!("Confidence: {:.2}", comp.confidence); // 0.85pub fn agent() -> Agentlet a = atp_sdk::agent();
println!("DID: {}", a.did()); // "did:key:z6Mk..."
println!("Public key: {}", a.public_key_hex()); // "a3f2b1c9..."
let sig = a.sign(b"hello");
assert!(a.verify(b"hello", &sig));
assert!(!a.verify(b"tampered", &sig));
// Display
println!("{a}"); // "Agent(did:key:z6Mk...abc)"
println!("{sig}"); // "Sig(a3f2b1c9...)"pub fn trust_score(skill: &str) -> TrustInfolet trust = atp_sdk::trust_score("coding");
println!("Score: {:.2}", trust.score); // 0.87
println!("Samples: {}", trust.samples); // 42All skill parameters accept case-insensitive strings with many aliases:
| Canonical | Aliases |
|---|---|
"coding" |
"code", "codegen", "code_generation", "cg"
|
"analysis" |
"analyze", "analyse"
|
"writing" |
"creative", "creative_writing", "cw"
|
"data" |
"processing", "data_processing", "dp"
|
For advanced use cases, you can create your own network:
use atp_sdk::Network;
let net = Network::new(); // 50 agents, seed 42
let net = Network::with_seed(123); // Custom seed
let route = net.route("coding");
let comp = net.compress(b"data", "coding");
let trust = net.trust("analysis");
let report = net.benchmark(10_000);
println!("Agents: {}", net.agents()); // 50
println!("{net}"); // "Network(50 agents, 247 edges, seed=42)"- Python SDK — Same API in Python
- Getting Started — Build your first ATP program
ATP Wiki
Getting Started
Architecture
- Architecture Overview
- Layer 1: Identity and Trust
- Layer 2: Capability Handshake
- Layer 3: Context Compression
- Layer 4: Economic Routing
- Layer 5: Fault Tolerance
Reference
More