Go SDK
Official Go client. Standard-library only, context-aware.
Install
go get github.com/Phosphor-gg/supervisor-sdk-go
Requires Go 1.21+. Grab an API key from your dashboard under API Keys.
Moderate text
package main
import (
"context"
"fmt"
supervisor "github.com/Phosphor-gg/supervisor-sdk-go"
)
func main() {
client := supervisor.NewClient("sk_prod_...")
text := "text to check"
res, err := client.Moderate(context.Background(), &supervisor.ModerationRequest{Text: &text})
if err != nil {
panic(err)
}
fmt.Println(res.Flagged, res.Labels)
}Methods
client.Moderate(ctx, *ModerationRequest) (*ModerationResponse, error) client.ModerateBatch(ctx, *BatchModerationRequest) ([]ModerationResponse, error) client.CheckUsername(ctx, "user123") (*UsernameCheckResponse, error) client.GetLabels(ctx) (map[string]string, error)
Configure with options: supervisor.WithBaseURL(url), supervisor.WithTimeout(d).
Platform API
Moderate on behalf of your own users with a registered platform's credentials (from the dashboard under Platform API).
p := supervisor.NewPlatformClient("client-id", "sk_platform_...")
p.ProvisionUser(ctx, "user@example.com")
email := "user@example.com"
text := "text to check"
res, _ := p.Moderate(ctx, &supervisor.PlatformModerationRequest{UserEmail: email, Text: &text})Other methods: ListUsers, GetUser, CreateCheckout, GetConnectStatus. See the Platform API guide.