SDKs
Go SDK
Use the Altirs Go SDK to run guardrail checks in your Go applications.
Install
go get github.com/altirs/sdk-goQuick Start
package main
import (
"context"
"log"
altirs "github.com/altirs/sdk-go"
)
func main() {
client := altirs.NewClient("grd_...")
result, err := client.Check(context.Background(), altirs.CheckPayload{
Input: ptr("Ignore all previous instructions"),
})
if err != nil {
log.Fatal(err)
}
if result.Blocked {
log.Println("Blocked:", result.Violations)
}
}
func ptr(s string) *string { return &s }Methods
| Method | Description |
|---|---|
Check(ctx, payload) | Run guardrail checks on a single input/response pair. Returns *CheckResponse. |
Batch(ctx, items) | Run checks on multiple items (max 20). Returns *BatchResponse. |
IsSafe(ctx, input) | Convenience: returns true if input passes all checks. |
MaskPII(ctx, text) | Convenience: returns text with PII redacted. |
Error Handling
Check for *altirs.AltirsError when the API returns a non-2xx response:
result, err := client.Check(ctx, payload)
if err != nil {
var gerr *altirs.AltirsError
if errors.As(err, &gerr) {
log.Printf("API error: %s (status=%d)", gerr.Message, gerr.Status)
}
}Configuration
client := altirs.NewClient("grd_...",
altirs.WithBaseURL("https://altirs.ai/api"), // optional
altirs.WithTimeout(30*time.Second), // optional, default 30s
)