fabric-platform 0.3.1

Rust client SDK for the Fabric platform
Documentation

fabric-platform

Rust client SDK for the Fabric AI workflow platform.

Installation

[dependencies]
fabric-platform = "0.1"
tokio = { version = "1", features = ["rt", "macros"] }

Quick Start

use fabric_sdk::FabricClient;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // API key auth
    let client = FabricClient::new("https://gofabric.dev", "fab_your_key")?;

    // Get the current principal
    let me = client.get_me().await?;
    println!("Logged in as: {:?}", me);

    // List organizations
    let orgs = client.get_my_organizations().await?;
    for org in &orgs {
        println!("Org: {}", org);
    }

    // Check a permission
    let allowed = client
        .check_permission("read", Some("organization:<org-id>"))
        .await?;
    println!("Allowed: {}", allowed);

    Ok(())
}

Features

  • Identityget_me, get_my_organizations, get_my_teams, get_my_permissions
  • Organizations & teams — create, list, update, member management
  • Workflows — register, run, wait for completion, list runs
  • Jobs — submit and track single-node jobs
  • Authorizationcheck_permission, check_permissions (batch)
  • API keys — create, list, rotate, disable
  • Providers — list, execute, estimate cost
  • Streaming — Server-Sent Events for live workflow updates

Authentication

The SDK supports two auth modes:

// API key (server-to-server)
let client = FabricClient::new("https://gofabric.dev", "fab_your_key")?;

// Bearer token (e.g. from /v1/auth/login)
let client = FabricClient::with_token("https://gofabric.dev", "jwt-token")?;

Authorization

Check permissions using the compound resource format ("type:id"):

// Single check
let allowed = client
    .check_permission("owner", Some(&format!("team:{team_id}")))
    .await?;

// Batch check (more efficient for multiple checks)
let results = client
    .check_permissions(vec![
        serde_json::json!({ "resource": format!("team:{team_id}"), "action": "owner" }),
        serde_json::json!({ "resource": format!("team:{team_id}"), "action": "admin" }),
        serde_json::json!({ "resource": format!("team:{team_id}"), "action": "read" }),
    ])
    .await?;

Workflows

// Register a workflow definition
let wf_id = client
    .upsert_workflow(
        "transcribe-and-summarize",
        serde_json::json!({
            "nodes": [
                {"key": "transcribe", "operation": "audio.transcribe"},
                {"key": "summarize", "operation": "ai.generate", "depends_on": ["transcribe"]}
            ]
        }),
    )
    .await?;

// Run it
let run_id = client
    .run_workflow(wf_id, serde_json::json!({ "audio": { "url": "..." } }))
    .await?;

// Wait for completion
let result = client.wait_for_run(run_id).await?;

Documentation

License

MIT