Versions in this module Expand all Collapse all v0 v0.1.1 Sep 30, 2026 v0.1.0 Sep 28, 2026 Changes in this version + const APIKeyEnv + const BaseURLEnv + const DefaultBaseURL + const DefaultConnectTimeout + const DefaultMaxResponseBytes + const DefaultModel + const DefaultModelEnv + const DefaultTimeout + const LevelTrace + const Version + var ErrClientClosed = errors.New("typesafe: the client is closed") + var ErrHTTP2NotNegotiated = errors.New("typesafe: the API host did not negotiate HTTP/2") + func Ask[T any](ctx context.Context, c *Client, state any, opts ...CallOption) (T, error) + func DecodeAs[T any](resp *SystemOneResponse) (T, error) + type APIError struct + Body []byte + Endpoint string + ErrorType string + Header http.Header + Kind APIErrorKind + Message string + StatusCode int + func (e *APIError) Error() string + func (e *APIError) IsAuthentication() bool + func (e *APIError) RequestID() (string, bool) + func (e *APIError) RetryAfter() (time.Duration, bool) + type APIErrorKind uint8 + const APIErrorAuthentication + const APIErrorBadRequest + const APIErrorInternalServer + const APIErrorNotFound + const APIErrorOther + const APIErrorPermissionDenied + const APIErrorRateLimit + const APIErrorUnprocessableEntity + func (k APIErrorKind) String() string + type Answer struct + func (a Answer) Choice() (ChoiceAnswer, bool) + func (a Answer) Kind() AnswerKind + func (a Answer) MarshalJSON() ([]byte, error) + func (a Answer) Noul() (NoulAnswer, bool) + func (a Answer) Score() (ScoreAnswer, bool) + type AnswerKind uint8 + const KindChoice + const KindNoul + const KindScore + func (k AnswerKind) String() string + type Answers struct + func (a Answers) All() iter.Seq2[string, Answer] + func (a Answers) Choice(name string) (ChoiceAnswer, bool) + func (a Answers) Choices() iter.Seq2[string, ChoiceAnswer] + func (a Answers) Get(name string) (Answer, bool) + func (a Answers) Len() int + func (a Answers) MarshalJSON() ([]byte, error) + func (a Answers) Noul(name string) (NoulAnswer, bool) + func (a Answers) Nouls() iter.Seq2[string, NoulAnswer] + func (a Answers) Score(name string) (ScoreAnswer, bool) + func (a Answers) Scores() iter.Seq2[string, ScoreAnswer] + type CallOption func(*callOptions) + func ExtraBody(key string, v any) CallOption + func Header(name, value string) CallOption + func Model(name string) CallOption + func Retry(policy RetryPolicy) CallOption + func Timeout(d time.Duration) CallOption + type Choice struct + Instructions Content + Options Options + type ChoiceAnswer struct + func (a ChoiceAnswer) Choice() string + func (a ChoiceAnswer) Confidence() float64 + func (a ChoiceAnswer) MarshalJSON() ([]byte, error) + func (a ChoiceAnswer) Present() bool + func (a ChoiceAnswer) Probabilities() iter.Seq2[string, float64] + func (a ChoiceAnswer) Probability(label string) (float64, bool) + type Client engine.Client[RetryPolicy] + func NewClient(opts ...ClientOption) (*Client, error) + func (c *Client) Close() error + func (c *Client) Models() Models + func (c *Client) Stats() Stats + func (c *Client) SystemOne(ctx context.Context, state any, qs *Prepared, opts ...CallOption) (*SystemOneResponse, error) + func (c *Client) WarmUp(ctx context.Context) error + type ClientOption func(*options) + func WithAPIKey(key string) ClientOption + func WithBaseURL(rawURL string) ClientOption + func WithClientTrace(trace *httptrace.ClientTrace) ClientOption + func WithCompression(enabled bool) ClientOption + func WithConnectTimeout(d time.Duration) ClientOption + func WithHTTPTransport(t *http.Transport) ClientOption + func WithHTTPVersion(v HTTPVersion) ClientOption + func WithHeader(name, value string) ClientOption + func WithLogEndpointHost(log bool) ClientOption + func WithLogger(logger *slog.Logger) ClientOption + func WithMaxResponseBytes(n int64) ClientOption + func WithModel(model string) ClientOption + func WithNoTimeout() ClientOption + func WithPretouch(types ...reflect.Type) ClientOption + func WithProxy(proxy func(*http.Request) (*url.URL, error)) ClientOption + func WithRetry(policy RetryPolicy) ClientOption + func WithRootCAs(pool *x509.CertPool) ClientOption + func WithRoundTripper(rt http.RoundTripper) ClientOption + func WithRuntimeHeader(send bool) ClientOption + func WithTLSConfig(cfg *tls.Config) ClientOption + func WithTimeout(d time.Duration) ClientOption + func WithUserAgentProduct(product string) ClientOption + type ConfigError struct + func (e *ConfigError) Error() string + func (e *ConfigError) Unwrap() []error + type ConnectionError struct + func (e *ConnectionError) Error() string + func (e *ConnectionError) Proxy() bool + func (e *ConnectionError) Unwrap() error + type Content struct + func JSON(raw []byte) Content + func Text(s string) Content + func (c Content) IsJSON() bool + func (c Content) IsZero() bool + func (c Content) JSON() RawJSON + func (c Content) MarshalJSON() ([]byte, error) + func (c Content) Text() string + type Error interface + type HTTPVersion int + const HTTP2Only + const HTTPAuto + func (v HTTPVersion) String() string + type InvalidRequestError struct + func (e *InvalidRequestError) Error() string + func (e *InvalidRequestError) Unwrap() error + type ModelCard struct + func (m ModelCard) Description() string + func (m ModelCard) MarshalJSON() ([]byte, error) + func (m ModelCard) Name() string + func (m ModelCard) ReleaseDate() string + type Models struct + func (m Models) List(ctx context.Context, opts ...CallOption) (*ModelsResponse, error) + type ModelsResponse struct + func (r *ModelsResponse) Meta() ResponseMeta + func (r *ModelsResponse) Models() []ModelCard + func (r *ModelsResponse) UnmarshalJSON(data []byte) error + func (r ModelsResponse) MarshalJSON() ([]byte, error) + type Noul struct + Instructions Content + No Content + Yes Content + type NoulAnswer struct + func (a NoulAnswer) MarshalJSON() ([]byte, error) + func (a NoulAnswer) Noul() float64 + func (a NoulAnswer) Present() bool + type Option struct + Description Content + Label string + type Options []Option + type Prepared engine.Prepared + func PreparedFor[T any]() (*Prepared, error) + func (p *Prepared) Len() int + func (p *Prepared) Names() iter.Seq[string] + type Questions struct + func NewQuestions() *Questions + func (qs *Questions) Choice(name string, q Choice) *Questions + func (qs *Questions) Noul(name string, q Noul) *Questions + func (qs *Questions) Prepare() (*Prepared, error) + func (qs *Questions) Raw(name string, q RawQuestion) *Questions + func (qs *Questions) Score(name string, q Score) *Questions + type RawJSON []byte + func (r RawJSON) MarshalJSON() ([]byte, error) + type RawQuestion struct + Fields map[string]any + Type string + type ResponseMeta struct + func (m ResponseMeta) Header() http.Header + func (m ResponseMeta) RawBody() []byte + func (m ResponseMeta) RequestID() (string, bool) + func (m ResponseMeta) StatusCode() int + type ResponseTooLargeError struct + Endpoint string + Header http.Header + Limit int64 + StatusCode int + func (e *ResponseTooLargeError) Error() string + func (e *ResponseTooLargeError) RequestID() (string, bool) + type ResponseValidationError struct + Body []byte + Endpoint string + FieldPath string + Header http.Header + StatusCode int + func (e *ResponseValidationError) Error() string + func (e *ResponseValidationError) RequestID() (string, bool) + func (e *ResponseValidationError) Unwrap() error + type RetryPolicy struct + func DefaultRetry() RetryPolicy + func NoRetry() RetryPolicy + func (p RetryPolicy) Backoff(initial, maximum time.Duration, jitter float64) RetryPolicy + func (p RetryPolicy) Budget(d time.Duration) RetryPolicy + func (p RetryPolicy) ConnectionErrors(retry bool) RetryPolicy + func (p RetryPolicy) MaxRetries(n int) RetryPolicy + func (p RetryPolicy) NoBudget() RetryPolicy + func (p RetryPolicy) Predicate(accept func(err error) bool) RetryPolicy + func (p RetryPolicy) RespectRetryAfter(respect bool) RetryPolicy + func (p RetryPolicy) Statuses(codes ...int) RetryPolicy + func (p RetryPolicy) TimeoutErrors(retry bool) RetryPolicy + type Score struct + Instructions Content + Levels []Content + type ScoreAnswer struct + func (a ScoreAnswer) Confidence() float64 + func (a ScoreAnswer) Description(level uint32) (Content, bool) + func (a ScoreAnswer) Legend() iter.Seq2[uint32, Content] + func (a ScoreAnswer) MarshalJSON() ([]byte, error) + func (a ScoreAnswer) Present() bool + func (a ScoreAnswer) Probabilities() iter.Seq2[uint32, float64] + func (a ScoreAnswer) Probability(level uint32) (float64, bool) + func (a ScoreAnswer) Score() float64 + type Stats struct + Attempts uint64 + Dials uint64 + type SystemOneResponse engine.Response + func (r *SystemOneResponse) Answers() Answers + func (r *SystemOneResponse) Meta() ResponseMeta + func (r *SystemOneResponse) Model() string + func (r *SystemOneResponse) UnmarshalJSON(data []byte) error + func (r *SystemOneResponse) Usage() Usage + func (r SystemOneResponse) MarshalJSON() ([]byte, error) + type TimeoutError struct + Timeout time.Duration + func (e *TimeoutError) Error() string + func (e *TimeoutError) Proxy() bool + func (e *TimeoutError) Unwrap() error + type Usage struct + func (u Usage) InputTokens() (uint64, bool) + func (u Usage) MarshalJSON() ([]byte, error) + func (u Usage) OutputTokens() (uint64, bool)