0211GitHub
typesafe-sdk-go
A Go client for the TypeSafe API.
RadixILS-Dev/typesafe-sdk-goREADME ↗
# TypeSafe AI Go SDK
[](https://github.com/RadixILS-Dev/typesafe-sdk-go/actions/workflows/ci.yml)
[](https://pkg.go.dev/github.com/RadixILS-Dev/typesafe-sdk-go)
A client for [TypeSafe AI](https://typesafe.ai). The wire
format and default retry behavior follow the
[Python SDK v0.6.0](https://github.com/typesafe-ai/typesafe-sdk-python/tree/420ef4ffb612d5a539a1e0f0fe883ff6770340af),
with a smaller, Go-native API.
## Quick start
Requires Go 1.26 or later. The module declares `go 1.26` as its minimum; CI
tests that version and the latest stable release.
```sh
go get github.com/RadixILS-Dev/typesafe-sdk-go
export TYPESAFE_API_KEY='your-api-key'
```
Import `github.com/RadixILS-Dev/typesafe-sdk-go` as package `typesafe`:
```go
client, err := typesafe.NewClient()
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
result, err := client.SystemOne(ctx, "I was charged twice. Please help ASAP.", typesafe.Questions{
"billing": typesafe.Noul{Instructions: "Is this about billing?"},
"tone": typesafe.Choice{
Instructions: "What is the tone?",
Criteria: map[string]string{"calm": "", "angry": ""},
},
"urgency": typesafe.Score{
Instructions: "How urgent is this?",
Criteria: []string{"low", "medium", "high"},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result.Nouls["billing"].Noul, result.Choices["tone"].Choice, result.Scores["urgency"].Score)
```
The complete program is in [`examples/basic/main.go`](examples/basic/main.go).
`go run ./examples/basic` makes a real API request.
## Configuration
`NewClient()` uses environment variables and defaults. For explicit settings:
```go
client, err := typesafe.NewClient(
typesafe.WithAPIKey("your-api-ke