typesafe-ai: Client for the TypeSafe AI System One API

[ ai, api, bsd3, library, web ] [ Propose Tags ] [ Report a vulnerability ]

A client for TypeSafe's System One API (https://docs.typesafe.ai): send text or JSON state with typed Noul (yes/no), Choice and Score questions, and get back answers that decode to your own Haskell types. . Built on http-client with TLS, connection reuse, per-attempt timeouts and retries with exponential backoff that honour Retry-After. . The types, JSON codecs and calls are in typesafe-ai-core, which has no HTTP dependency, so they can also be used with servant or any other HTTP stack. . Start with TypeSafe and TypeSafe.Tutorial. . This is a community SDK, not affiliated with or endorsed by TypeSafe AI.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0
Change log CHANGELOG.md
Dependencies base (>=4.18 && <4.23), bytestring (>=0.11.3 && <0.13), http-client (>=0.7.13 && <0.8), http-client-tls (>=0.3.6.2 && <0.5), http-types (>=0.12.3 && <0.13), random (>=1.2 && <1.4), text (>=2.0 && <2.2), time (>=1.12 && <1.17), typesafe-ai-core (>=0.1.0.0 && <0.1.1) [details]
Tested with ghc ==9.6.7 || ==9.8.4 || ==9.10.3 || ==9.12.2 || ==9.14.1
License BSD-3-Clause
Copyright 2026 byteally
Author Magesh B
Maintainer magesh85@gmail.com
Uploaded by magesh at 2026-09-22T14:59:09Z
Category AI, Web, API
Home page https://github.com/byteally/typesafe-sdk
Bug tracker https://github.com/byteally/typesafe-sdk/issues
Source repo head: git clone https://github.com/byteally/typesafe-sdk.git(typesafe-ai)
Distributions
Downloads 0 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for typesafe-ai-0.1.0.0

[back to package description]

typesafe-ai

A Haskell client for TypeSafe AI's System One API. Send text or JSON state with typed questions, and get back answers that decode to your own Haskell types.

{-# LANGUAGE DeriveAnyClass, DeriveGeneric, DerivingStrategies, OverloadedStrings #-}

import GHC.Generics (Generic)
import TypeSafe

data Department = Billing | Technical | Sales
  deriving stock (Show, Eq, Generic)
  deriving anyclass (ChoiceOption)

main :: IO ()
main = do
  client <- newClientFromEnv -- reads TYPESAFE_API_KEY
  result <-
    send client $
      systemOne "Help! My payouts have been failing for 3 days." $
        (,) <$> ask "department" (choice "Which team should handle this?")
            <*> ask "is_urgent" (noul "Does this convey urgency?")
  let (department, urgent) = evaluationAnswers result
  print (choiceSelected department :: Department, choiceConfidence department)
  print (noulProbability urgent)
  • Choice options and Score levels are your own types; the answer can only be one of them.
  • Questions combine with Applicative, and many questions fit in one request.
  • Built on http-client, with a shared TLS connection pool, per-attempt timeouts, and retries with exponential backoff that honour Retry-After.
  • Errors are values that separate local validation, error responses, connection failures and unexpected responses.

Read TypeSafe.Tutorial for a guided tour. The types, codecs and calls live in typesafe-ai-core, which has no HTTP dependency. The repository has runnable examples.

This is a community SDK, not affiliated with or endorsed by TypeSafe AI.