Open-source Go SDK · Python v0.7.0 parity

TypeSafe SDK
for Go

Ask an AI model bounded questions about any text. Get typed answers back, and keep every decision in plain Go.

$ go get github.com/captain-corgi/typesafe-sdk-go
0runtime dependencies
3typed primitives
91runnable examples
The problem

A model returns prose. Your code needs a value it can branch on.

Parse free text

reply := complete(prompt) if strings.Contains(reply, "urgent") { // "not urgent" also matches }
  • Output format drifts between calls
  • No confidence to set a threshold on
  • Retries, timeouts, and errors by hand

Ask a typed question

"urgent": typesafe.Noul{...} // answer: NoulAnswer{Noul: 0.91} if resp.Nouls()["urgent"].Noul >= 0.8 { ... }
  • The question kind fixes the answer type
  • Probabilities you can measure and tune
  • Validation, retries, and errors built in
The solution

Three question kinds. Each has its own answer type.

Noul

Yes or no, as a probability

"Is this urgent?"
.Noul → 0.91
Choice

Pick one label

billing · technical · account
.Choice → "billing"
Score

Place on an ordered rubric

calm → annoyed → upset
.Score → 1.4
Raw

Pass a shape through

Fields this SDK version does not model
sent untouched
In code

One call. Your policy stays in Go.

  1. Describe the stateA ticket, a diff, a log line, any text.
  2. Ask named questionsMix kinds freely in one request.
  3. Branch on typed answersif and switch, with thresholds you measured.
triage.go
resp, err := client.SystemOne(ctx, &typesafe.SystemOneParams{
    State: ticket.Body,
    Questions: typesafe.Questions{
        "urgent": typesafe.Noul{Instructions: "Is this urgent?"},
        "topic": typesafe.Choice{
            Instructions: "What is this about?",
            Criteria: typesafe.ChoiceCriteria{
                "billing": "Charges or invoices",
                "bug":     "Something is broken",
            },
        },
    },
})
if err != nil {
    return err
}

if resp.Nouls()["urgent"].Noul >= 0.8 &&
    resp.Choices()["topic"].Choice == "billing" {
    page(billingOnCall)
}
How it works

The SDK handles the path between your code and the API.

Input

State and named questions

Validate

Checked before any network I/O

Send + retry

429, 5xx, timeouts: backoff with jitter

Decode

Nouls(), Choices(), Scores()

Your Go

if / switch on typed values

Failures match with errors.As:*RateLimitError*TimeoutError*ResponseValidationError
Why this SDK

Small surface. Production defaults.

Zero dependencies

Standard library only. CI proves it.

Typed answers

Noul, Choice, and Score map to their own structs.

Smart retries

Backoff, jitter, Retry-After, per-call budget.

Structured errors

One taxonomy, matched with errors.As.

Safe for concurrency

One client per process, verified with -race.

Secure by default

HTTPS only, secrets redacted from slog logs.

Proof in code

91 runnable examples, each with a diagram.

Question kinds used:
Get started

Install it, set TYPESAFE_API_KEY, and ask your first question.

$ go get github.com/captain-corgi/typesafe-sdk-go

MIT licensed · community maintained · not affiliated with TypeSafe AI