0490GitHub
typesafe-go
Idiomatic Go SDK for the TypeSafe API.
zhirschtritt/typesafe-goREADME ↗
# TypeSafe Go SDK
[](https://pkg.go.dev/github.com/zhirschtritt/typesafe-go)
An **unofficial community SDK** for the [TypeSafe](https://www.typesafe.ai/) v1 API. It provides a small, dependency-free Go client for System One and model discovery.
> This project is not affiliated with or endorsed by TypeSafe.
## Install
```sh
go get github.com/zhirschtritt/typesafe-go
```
Requires Go 1.23 or later.
## Quickstart
```go
package main
import (
"context"
"fmt"
"log"
typesafe "github.com/zhirschtritt/typesafe-go"
)
func main() {
client, err := typesafe.NewClient()
if err != nil {
log.Fatal(err)
}
response, err := client.SystemOne(context.Background(),
map[string]any{
"draft": "Ship the migration on Friday.",
"author": "Avery",
},
map[string]typesafe.Question{
"safe": typesafe.Noul("Is the draft safe to send?", nil),
"audience": typesafe.Choice("Which audience should receive the draft?", map[string]typesafe.Entry{
"engineering": "Technical stakeholders",
"customers": "External customers",
}),
"feasibility": typesafe.Score("How feasible is shipping the migration on Friday?",
"Not feasible", "At risk", "Feasible",
),
},
)
if err != nil {
log.Fatal(err)
}
safe, _ := response.NoulAnswer("safe")
audience, _ := response.ChoiceAnswer("audience")
feasibility, _ := response.ScoreAnswer("feasibility")
fmt.Printf("safe=%.2f audience=%s feasibility=%.2f request_id=%s\n",
safe.Noul, audience.Choice, feasibility.Score, response.RequestID)
}
```
## Configuration
| Variable | Purpose |
| --- | --- |
| `TYPESAFE_API_KEY` | API key (required unless supplied with a client option) |
| `TYPESAFE_BASE_URL` | API base URL override |
| `TYPESAFE_DEFAULT_MODEL` | Default model override |
Use client options to configure a key,