Documentation
¶
Overview ¶
Package provider holds a decision.Provider for each vendor whose System One endpoint the SDK has been checked against, to pass to decision.WithProvider:
client, err := decision.NewClient(decision.WithProvider(provider.Codiv()))
Each preset names the vendor's base URL, its paths and the environment variable its key is read from. A vendor-named variable is read only by its own preset, so a key kept for one vendor is sent to that vendor's host alone; with a preset, the generic DECISION_MODEL_ variables are not read. Only OpenAI carries a default model; with any other preset, name one with decision.WithModel or with decision.Model on each call.
TypeSafe, Codiv, Perplexity, OpenRouter and OpenRouterDecisions speak System One. DecisionsAPI and OpenAI do not, and each carries a decision.Dialect that rewrites every call between the SDK's wire and the vendor's, so that a call reads the same on every preset; each one's documentation says what its wire cannot express.
The vendors differ in what they do with a top-level request member they do not know, such as one decision.ExtraBody adds: each preset's documentation says which.
This "provider" is a vendor of the System One API that the client calls; the adapter module's providers are the language models its local stand-in for the API drives, a different thing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Codiv ¶
Codiv returns the provider of Codiv's API: https://api.codiv.ai, POST /v1/systemone and GET /v1/models, with the key read from CODIV_API_KEY.
Its listing named the models openjev-latest, openjev-0.1, diffusiongemma-26b, laya-1.0, verdict-1.4, clm-v0.1 and jevk5-0.2; the listing may hold models its System One endpoint does not serve. It ignores a top-level member it does not know, such as one decision.ExtraBody adds, and answers as if the member were absent.
func DecisionsAPI ¶
DecisionsAPI returns the provider of Decisions API: https://decisions-api.dev, POST /v1/systemone, with the key read from DECISIONS_API_KEY. It is not decisionapi.net, a vendor of its own whose key goes by DECISIONAPI_API_KEY, which this preset never reads.
It takes the System One request unchanged and answers inside an envelope: {"code":0,"message":"ok","data":{"requestId":...,"result":{...},...}}, where data.result is the System One response. The preset's decision.Dialect hands the decoder data.result and drops the rest of the envelope, so a response's decision.ResponseMeta.RawBody is data.result, and a 2xx whose code is not 0 or that has no data.result is a *decision.ResponseValidationError at "code" or "data.result". Its errors are {"code":-1,"message":...} with the HTTP status; an *decision.APIError keeps that body, takes its Message from "message", and has the ErrorType authentication_error for 401 and api_usage_error for 400 (an unknown model, whose message lists the models it accepts).
It sends x-request-id on a success only, so a response's RequestID holds the id and an APIError's reports none; the envelope's data.requestId, the same id, is dropped with the envelope.
It refuses, with status 400, a yes/no question that describes its Yes outcome without its No outcome, with a message asking for both. It has no listing, so ModelsPath is empty and decision.Models.List on its client fails with a *decision.ConfigError before anything is sent; it names models as vendor/model, such as typesafe/jev-1.13, and also takes jev-latest. It ignores a top-level member it does not know, such as one decision.ExtraBody adds.
func OpenAI ¶
OpenAI returns the provider of OpenAI's decisions API: https://api.openai.com, POST /v1/decisions, with the key read from OPENAI_API_KEY and gpt-6-luna as the model of a call that names none (decision.WithModel and decision.Model still win).
Its wire is not System One's, and the preset's decision.Dialect rewrites each call. The request becomes {"model", "input", "questions"}: input is the state, its text when the state is text and its compact JSON otherwise; each question is {"type", "name", "instructions", ...} with type predicate for a yes/no question, choice with "choices" of {"value", "description"} for a choice, and score with "levels" of {"label"} for a score. The answers come back as an array of {"type", "name", ...} with probabilities as arrays of objects; the dialect reads them back as the System One response, the score's legend taken from the request's levels, so decision.Ask, decision.DecodeAs and Answers work as on any other provider. A response's decision.ResponseMeta.RawBody is that System One body. The usage keeps input_tokens and output_tokens.
The dialect refuses, before anything is sent and with a *decision.DialectError, a call the vendor's wire cannot express: a question added with decision.Questions.Raw; instructions, a choice's option description or a score level given as decision.JSON content; a yes/no question with a Yes or a No outcome, which a predicate has no room for. A member decision.ExtraBody adds is copied to the top level of the request, where OpenAI refuses one it does not know with status 400 (unknown_parameter).
Its errors are {"error":{"message","type","param","code"}}, whose type is invalid_request_error even for a wrong key; an *decision.APIError keeps that body, takes its Message from error.message, and has the ErrorType authentication_error for 401 and api_usage_error for 400 and 404 (an unknown model). The message of a 401 for a wrong key repeats the key's first and last characters. It sends x-request-id on every response.
Its GET /v1/models lists every model of the account, not only those its decisions API serves, in a shape that is not System One's, so ModelsPath is empty and decision.Models.List on its client fails with a *decision.ConfigError before anything is sent.
func OpenRouter ¶
OpenRouter returns the provider of OpenRouter's System One endpoint: https://openrouter.ai, POST /api/v1/systemone, with the key read from OPENROUTER_API_KEY, which OpenRouterDecisions reads too. It takes the System One request and answers in the System One response shape, with the members id, provider and usage.cost besides, which the SDK ignores.
OpenRouter names a System One model with its vendor: typesafe/jev-1.13. The bare id jev-1.13 was accepted too and answered under the namespaced one, the response's model being typesafe/jev-1.13-20260917 for either; the vendor's reference page states that mapping for every System One id.
It has no listing in the System One shape (its GET /api/v1/models lists OpenRouter's whole catalogue of chat models, in a shape of its own), so ModelsPath is empty and decision.Models.List on its client fails with a *decision.ConfigError before anything is sent.
It sends no x-request-id or x-typesafe-request-id header. A success carries x-generation-id, equal to the body's id, and x-provider-name instead, which the SDK does not read, so Meta().RequestID() and decision.APIError.RequestID report none. Its error body is {"error":{"message","code"}}: decision.APIError.Message holds the message, and decision.APIError.ErrorType is empty: its error bodies, 400 and 401 among those recorded, carry no error_type.
It ignores a top-level request member it does not know, such as one decision.ExtraBody adds, and answers as if the member were absent. It refuses, with status 400, a noul question whose criteria describe only the true outcome (the error names criteria.false as required); a noul with no criteria is accepted.
func OpenRouterDecisions ¶
OpenRouterDecisions returns the provider of OpenRouter's alpha decisions endpoint: https://openrouter.ai, POST /api/alpha/decisions, with the key read from OPENROUTER_API_KEY, the variable OpenRouter reads, so one key serves both. The path has no /v1, and the vendor marks the endpoint alpha: /api/v1/alpha/decisions and /api/v1/api/alpha/decisions both answer 404.
It takes the same request and gives the same answers, request id, listing (none), error body, treatment of an unknown member and refusal of a true-only noul as OpenRouter; its documentation has the details, among them the namespaced model ids such as typesafe/jev-1.13.
func Perplexity ¶
Perplexity returns the provider of Perplexity's decisions API: https://api.perplexity.ai, POST /v1/decisions, with the key read from PERPLEXITY_API_KEY. It takes the System One request and answers in the System One response shape.
It has no listing in the System One shape (its GET /v1/models lists another product's models), so ModelsPath is empty and decision.Models.List on its client fails with a *decision.ConfigError before anything is sent. Its decision model is pplx-decider-v1.1-27b. It refuses a request with a top-level member it does not know, such as one decision.ExtraBody adds, with status 400.
func TypeSafe ¶
TypeSafe returns the provider of TypeSafe AI's API, which offered System One first: https://api.typesafe.ai, POST /v1/systemone and GET /v1/models, with the key read from TYPESAFE_API_KEY.
Its listing named the models jev-latest and jev-preview. It refuses a request with a top-level member it does not know, such as one decision.ExtraBody adds, with status 400.
Types ¶
This section is empty.