Skip to content

Go SDK

The certivu Go module is a thin REST client for signing and verifying AI-generated content. It targets the highest-volume Certivu actor — verifiers wiring POST /v1/verify into content ingest, moderation, and CI — plus generator-side backends.

Like every Certivu SDK, it does no client-side cryptography. Signing happens server-side (org private keys and signing quota live behind the API) and verification goes through the API. The module never bundles ML-DSA.

The SDK is distributed from cdn.certivu.ai as a static Go module proxy — not from a public GitHub repo. Point go at the CDN proxy (keeping the public proxy as a fallback for your other dependencies) and skip the checksum DB for cdn.certivu.ai, then go get it:

Terminal window
go env -w GOPROXY=https://cdn.certivu.ai/sdk/go,https://proxy.golang.org,direct
go env -w GONOSUMDB=cdn.certivu.ai
go get cdn.certivu.ai/sdk/[email protected]

The CDN proxy is tried first; anything it doesn’t serve (your other deps) falls through to proxy.golang.org. GONOSUMDB=cdn.certivu.ai skips sum.golang.org for this module only. (A plain GOPRIVATE=cdn.certivu.ai go get … also works if the CDN serves the module’s ?go-get=1 discovery page.)

import certivu "cdn.certivu.ai/sdk/go"

Requires Go 1.22+. The module has zero dependencies — standard library only. Pin a version with @v1.0.0. The Go SDK versions on its own line (starting v1.0.0), independent of the Certivu platform version, to keep the import path free of a /v2 suffix.

client := certivu.New(
"ctv_key_abc123", // omit (pass "") for verify-only
certivu.WithGeneratorID("your-generator-uuid"), // required for signing
)

Options:

  • WithBaseURL(url) — point at the sandbox (https://api-sandbox.certivu.ai).
  • WithGeneratorID(id) — default generator for Sign / SignBatch.
  • WithTimeout(d) — HTTP timeout (default 60s; watermarking takes a moment).
  • WithHTTPClient(hc) — supply your own *http.Client for proxies or custom transports.

The *Client is safe for concurrent use. Every method takes a context.Context first.


img, _ := os.ReadFile("output.png") // or .mp3, .mp4, .pdf, etc.
res, err := client.Sign(context.Background(), img, "stable-diffusion-xl")
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Token) // ctv_7f3kx9mq2...
fmt.Println(res.RecordID) // rec-uuid
os.WriteFile("output.signed.png", res.SignedContent, 0o644) // store THIS

res.SignedContent is the signed content with the ctv_ token injected into a format-native container (XMP, ID3v2, HTML meta, cerv atom, …) and the watermark embedded — deliver it instead of the original. Pass certivu.WithFormat("image") to skip auto-detection.

When the API recognises identical input bytes it re-uses the existing record without charging a new signature; res.Deduplicated is then true.

results, err := client.SignBatch(context.Background(), []certivu.SignItem{
{Content: a, Model: "sdxl"},
{Content: b, Model: "sdxl", Format: "image"},
})
for i, r := range results {
if r.Err != nil {
log.Printf("item %d failed: %v", i, r.Err)
continue
}
fmt.Println(r.Result.Token)
}

Verification is free, unlimited, and needs no API key — construct a verify-only client with an empty key:

client := certivu.New("")
res, err := client.Verify(context.Background(), contentBytes)
if err != nil {
log.Fatal(err)
}
fmt.Println(res.Authentic, res.Confidence) // e.g. true high
if res.Provenance != nil {
fmt.Printf("signed by %s using %s\n", res.Provenance.Org, res.Provenance.Model)
}

Pass certivu.WithToken("ctv_...") to take the fast path when you already hold the token. Verification works on transformed copies (resized, recompressed, reposted) via watermark, pHash, and fingerprint recovery.

status, err := client.TokenStatus(context.Background(), "ctv_...")
fmt.Println(status.Model, status.GeneratorStatus, status.OrgName)

This CDN-cacheable lookup powers badges and certificate pages without re-hashing content.


Any non-2xx response is returned as *certivu.APIError. Recover it with errors.As and branch with the predicate helpers:

_, err := client.Sign(ctx, img, "sdxl")
var apiErr *certivu.APIError
if errors.As(err, &apiErr) {
switch {
case apiErr.IsQuota(): // 402 — free-tier signing limit
log.Printf("upgrade at %s", apiErr.UpgradeURL)
case apiErr.IsAuth(): // 401 — bad / missing key
log.Print("invalid API key")
case apiErr.IsValidation(): // 400
log.Print(apiErr.Message)
default:
log.Printf("certivu error %d: %s", apiErr.StatusCode, apiErr.Message)
}
}

overview, _ := client.AnalyticsOverview(ctx, 30) // lookback days (plan-gated; 0 = default)
page, _ := client.AuditLog(ctx, 1, 20) // page, limit
rec, _ := client.RecordAnalytics(ctx, "rec-uuid") // Growth+
wh, _ := client.CreateWebhook(ctx, "https://hooks.example/certivu", []string{"tamper.detected"})
fmt.Println(wh.Secret) // shown ONCE — store it to verify delivery signatures

Enterprise plans can pull an EU AI Act compliance attestation:

att, _ := client.Attestation(ctx, "", "") // default last-90-days window
html, _ := client.ExportAttestation(ctx, "html", "", "") // rendered document string

  • No client crypto. Signing and verification are both API calls; offline verification is not supported.
  • Zero dependencies. Standard library only — safe for locked-down infra and CI environments.
  • Module path is cdn.certivu.ai/sdk/go, served as a static module proxy from the CDN (no GitHub). Releases are published to cdn.certivu.ai/sdk/go/@v/.