Versions in this module Expand all Collapse all v0 v0.1.0 Sep 24, 2026 Changes in this version + const APIKeyEnv + const AnswerChoice + const AnswerNoul + const AnswerScore + const BaseURLEnv + const DefaultBaseURL + const DefaultModel + const DefaultTimeout + const ModelEnv + const Version + var ErrAuthentication = errors.New("jev: authentication failed") + var ErrBadRequest = errors.New("jev: bad request") + var ErrConnection = errors.New("jev: connection failed") + var ErrInternalServer = errors.New("jev: server error") + var ErrInvalidConfig = errors.New("jev: invalid configuration") + var ErrInvalidRequest = errors.New("jev: invalid request") + var ErrInvalidResponse = errors.New("jev: invalid response") + var ErrNoAPIKey = errors.New("jev: no API key") + var ErrNotFound = errors.New("jev: not found") + var ErrOverloaded = errors.New("jev: service overloaded") + var ErrPermissionDenied = errors.New("jev: permission denied") + var ErrRateLimit = errors.New("jev: rate limit exceeded") + var ErrTimeout = errors.New("jev: request timed out") + var ErrUnprocessableEntity = errors.New("jev: unprocessable entity") + func RetryableStatus(status int) bool + func SystemOneAs[T any](ctx context.Context, client *Client, state any, questions Questions, ...) (T, error) + type APIError struct + Body []byte + Endpoint string + Message string + RequestID string + RetryAfter time.Duration + Status int + func (e *APIError) Error() string + func (e *APIError) Is(target error) bool + type Answer struct + Choice *ChoiceAnswer + Noul *NoulAnswer + Raw json.RawMessage + Score *ScoreAnswer + Type string + func (a *Answer) UnmarshalJSON(data []byte) error + func (a Answer) Known() bool + func (a Answer) MarshalJSON() ([]byte, error) + type CallOption interface + func UsingExtraBody(fields map[string]any) CallOption + func UsingHeader(name, value string) CallOption + func UsingModel(model string) CallOption + func UsingRetry(policy RetryPolicy) CallOption + func UsingTimeout(timeout time.Duration) CallOption + type Choice struct + Criteria map[string]any + Instructions any + func (q Choice) MarshalJSON() ([]byte, error) + type ChoiceAnswer struct + Choice string + Confidence float64 + Probabilities map[string]float64 + func (a *ChoiceAnswer) UnmarshalJSON(data []byte) error + type Client struct + func New(options ...Option) (*Client, error) + func (c *Client) Models(ctx context.Context, options ...CallOption) ([]Model, error) + func (c *Client) SystemOne(ctx context.Context, state any, questions Questions, options ...CallOption) (*SystemOneResponse, error) + func (c Client) GoString() string + func (c Client) LogValue() slog.Value + func (c Client) String() string + type ConnectionError struct + Endpoint string + Timeout bool + func (e *ConnectionError) Error() string + func (e *ConnectionError) Is(target error) bool + func (e *ConnectionError) Unwrap() error + type Model struct + Description string + Name string + ReleaseDate string + type Noul struct + Criteria *NoulCriteria + Instructions any + func (q Noul) MarshalJSON() ([]byte, error) + type NoulAnswer struct + Noul float64 + func (a *NoulAnswer) UnmarshalJSON(data []byte) error + type NoulCriteria struct + False any + True any + type Option func(*Client) + func WithAPIKey(key string) Option + func WithBaseURL(baseURL string) Option + func WithHTTPClient(httpClient *http.Client) Option + func WithHeader(name, value string) Option + func WithLogger(logger *slog.Logger) Option + func WithModel(model string) Option + func WithRetry(policy RetryPolicy) Option + func WithTimeout(timeout time.Duration) Option + type Question interface + type Questions map[string]Question + type RawQuestion struct + Fields map[string]any + Type string + func (q RawQuestion) MarshalJSON() ([]byte, error) + type ResponseValidationError struct + Body []byte + Endpoint string + FieldPath string + RequestID string + Status int + func (e *ResponseValidationError) Error() string + func (e *ResponseValidationError) Is(target error) bool + type RetryPolicy struct + Budget time.Duration + InitialBackoff time.Duration + Jitter float64 + MaxBackoff time.Duration + MaxRetries int + RespectRetryAfter bool + RetryConnection bool + RetryStatus func(status int) bool + func DefaultRetry() RetryPolicy + func NoRetry() RetryPolicy + type Score struct + Criteria []any + Instructions any + func (q Score) MarshalJSON() ([]byte, error) + type ScoreAnswer struct + Confidence float64 + Legend map[int]any + Probabilities map[int]float64 + Score float64 + func (a *ScoreAnswer) UnmarshalJSON(data []byte) error + type SystemOneResponse struct + Answers map[string]Answer + Header http.Header + Model string + RawBody json.RawMessage + RequestID string + Status int + Usage Usage + func (r *SystemOneResponse) ChoiceOf(name string) (ChoiceAnswer, bool) + func (r *SystemOneResponse) Choices() map[string]ChoiceAnswer + func (r *SystemOneResponse) NoulOf(name string) (float64, bool) + func (r *SystemOneResponse) Nouls() map[string]NoulAnswer + func (r *SystemOneResponse) ScoreOf(name string) (ScoreAnswer, bool) + func (r *SystemOneResponse) Scores() map[string]ScoreAnswer + func (r *SystemOneResponse) Unknown() map[string]Answer + func (r *SystemOneResponse) UnmarshalJSON(data []byte) error + type Usage struct + InputTokens int + OutputTokens int