Resolves where a request goes and how its response is shaped.
| provider | endpoint | auth | default model | envelope |
|---|---|---|---|---|
:typesafe (default) | https://api.typesafe.ai/v1/systemone | TYPESAFE_API_KEY | jev-latest | top level |
:cloudflare | .../accounts/{account_id}/ai/run/@cf/cloudflare/clef | CLOUDFLARE_API_TOKEN | @cf/cloudflare/clef | result |
:openrouter | https://openrouter.ai/api/alpha/decisions | OPENROUTER_API_KEY | typesafe/jev-1.13 | top level |
:openai | https://api.openai.com/v1/decisions | OPENAI_API_KEY | gpt-6-luna | translated (see SystemOneClient.Wire.OpenAIDecisions) |
:compatible | url: (required) | optional | none | top 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
Resolves the endpoint, auth, default model, envelope and wire format for a request.
Extracts the System One body from a provider's response envelope.
Types
@type envelope() :: :top_level | :cloudflare_result
@type name() :: :typesafe | :cloudflare | :openai | :openrouter | :compatible
@type wire() :: :system_one | :openai_decisions
Functions
@spec resolve(SystemOneClient.options()) :: {:ok, t()} | {:error, :missing_api_key | :missing_account_id | :missing_url | {:unknown_provider, term()}}
Resolves the endpoint, auth, default model, envelope and wire format for a request.
iex> {:ok, p} = SystemOneClient.Provider.resolve(provider: :openai, api_key: "sk-test")
iex> {p.url, p.model, p.wire}
{"https://api.openai.com/v1/decisions", "gpt-6-luna", :openai_decisions}
iex> SystemOneClient.Provider.resolve(provider: :typesafe, env: %{})
{:error, :missing_api_key}
Extracts the System One body from a provider's response envelope.