Rust SDK
Official async Rust client built on reqwest + tokio.
Install
[dependencies]
supervisor-sdk = { git = "https://github.com/Phosphor-gg/supervisor-sdk-rust" }
tokio = { version = "1", features = ["full"] }
Grab an API key from your dashboard under API Keys.
Moderate text
use supervisor_sdk::{SupervisorClient, ModerationRequest};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = SupervisorClient::new("sk_prod_...")?;
let res = client.moderate(ModerationRequest {
text: Some("text to check".into()),
..Default::default()
}).await?;
println!("{} {:?}", res.flagged, res.labels);
Ok(())
}
Methods
client.moderate(ModerationRequest) -> Result<ModerationResponse>
client.moderate_batch(BatchModerationRequest) -> Result<Vec<ModerationResponse>>
client.moderate_video(&[u8]) -> Result<VideoModerationResponse>
client.moderate_video_with(&[u8], model, enabled_labels) -> Result<VideoModerationResponse>
client.check_username("user123") -> Result<UsernameCheckResponse>
client.get_labels() -> Result<HashMap<String, String>>
A VideoModerationResponse carries flagged, labels (the union across frames), frames (each with timestamp_ms, flagged and labels), frames_analysed, duration_secs, codec and decoder. The 10 MB size limit is checked locally, so an oversized clip errors before it is uploaded.
Use SupervisorClient::with_base_url(key, url) to point at a custom base URL.
Platform API
Moderate on behalf of your own users with a registered platform's credentials (from the dashboard under Platform API).
use supervisor_sdk::{PlatformClient, PlatformModerationRequest};
let p = PlatformClient::new("client-id", "sk_platform_...")?;
p.provision_user("user@example.com").await?;
let res = p.moderate(PlatformModerationRequest {
user_email: "user@example.com".into(),
text: Some("text to check".into()),
..Default::default()
}).await?;
Other methods: list_users, get_user, create_checkout, get_connect_status. See the Platform API guide.