SystemOneClient.Provider (SystemOneClient v0.1.0)

Copy Markdown View Source

Resolves where a request goes and how its response is shaped.

providerendpointauthdefault modelenvelope
:typesafe (default)https://api.typesafe.ai/v1/systemoneTYPESAFE_API_KEYjev-latesttop level
:cloudflare.../accounts/{account_id}/ai/run/@cf/cloudflare/clefCLOUDFLARE_API_TOKEN@cf/cloudflare/clefresult
:openrouterhttps://openrouter.ai/api/alpha/decisionsOPENROUTER_API_KEYtypesafe/jev-1.13top level
:compatibleurl: (required)optionalnonetop level

url: and model: options always win over provider defaults. Keys come from api_key: or the provider's environment variable; env: can replace the environment in tests.

Summary

Functions

Extracts the System One body from a provider's response envelope.

Types

envelope()

@type envelope() :: :top_level | :cloudflare_result

t()

@type t() :: %{
  provider: atom(),
  url: String.t(),
  auth: {:bearer, String.t()} | nil,
  model: String.t() | nil,
  envelope: envelope()
}

Functions

resolve(opts)

@spec resolve(keyword()) :: {:ok, t()} | {:error, term()}

unwrap(atom, body)

@spec unwrap(envelope(), map()) :: {:ok, map()} | {:error, term()}

Extracts the System One body from a provider's response envelope.