Go SDK
github.com/sallines-ai/sdk-go with context and retries.
The Go SDK is github.com/sallines-ai/sdk-go. It uses context.Context for cancellation, honors X-Sallines-* headers, and unmarshals object: sallines.inference.response.
Install
go get github.com/sallines-ai/sdk-go
Requires Go 1.21 or later.
Client
package main
import (
"context"
"os"
"time"
"github.com/sallines-ai/sdk-go/sallines"
)
func main() {
client := sallines.NewClient(
sallines.WithAPIKey(os.Getenv("SALLINES_API_KEY")),
sallines.WithProjectID("prj_legal_001"),
sallines.WithTimeout(30*time.Second),
sallines.WithRetryPolicy(sallines.RetryPolicy{MaxAttempts: 3}),
)
_ = client
}
Inference
resp, err := client.Inference.Create(context.Background(), &sallines.InferenceRequest{
Model: "auto",
ProjectID: "prj_legal_001",
Messages: []sallines.Message{
{Role: "user", Content: "Summarize termination risk."},
},
Features: []string{"pii_redaction", "semantic_cache"},
IdempotencyKey: "contract-summary-4821-v1",
})
if err != nil {
panic(err)
}
fmt.Println(resp.Object) // sallines.inference.response
fmt.Println(resp.Sallines.Route) // gpt or gemini
fmt.Println(resp.Sallines.CostUSD)
Streaming
stream, err := client.Inference.Stream(ctx, &sallines.InferenceRequest{
Model: "auto",
ProjectID: "prj_legal_001",
Messages: []sallines.Message{{Role: "user", Content: "Draft the notice."}},
})
if err != nil {
return err
}
defer stream.Close()
for stream.Next() {
chunk := stream.Chunk()
fmt.Print(chunk.Choices[0].Delta.Content)
}
return stream.Err()
Errors
var apiErr *sallines.Error
if errors.As(err, &apiErr) {
log.Printf("code=%s request_id=%s status=%d", apiErr.Code, apiErr.RequestID, apiErr.Status)
}
sallines.Error surfaces rate_limit_exceeded, budget_exceeded, residency_violation, and model_unavailable as Code. Retry policy retries 408, 429, and 503 only.
Context and residency
Pass a deadline that exceeds routing timeout_ms. Set WithRegion("eu-west-1") on the client when the process is dedicated to one pin. Per-request Region on InferenceRequest must match the project pin when fail_closed is true.
Production API credentials are issued with an institution workspace. Contact sales if you need access.