Client settings, merged from layers: the SDK's generated defaults, then the application environment, then the options of a single call.
# config/runtime.exs
config :openai_sdk, api_key: System.fetch_env!("OPENAI_API_KEY"), max_retries: 5
# one call
OpenAI.Models.list(%{}, timeout: 5_000, max_retries: 0)Settings:
:base_url: where requests go:api_key: the credential, as a string,{user, password}for basic auth,{:env, "VAR"}(read on each request) or a 0-arity function:auth: how the credential is sent::bearer,:basic,{:header, "x-api-key"},{:query, "key"}, ornil:headers: extra headers,[{"name", "value"}]; a later layer replaces a header of the same name:timeout: milliseconds to wait for a response (default 10 minutes):max_retries: retries after the first attempt (default 2):idempotency_header: when set, every non-GET request gets this header with a key that stays the same across its retries:retry_count_header: when set, each request says which retry it is:request_id_headers: response headers holding the API's request ID:form_style: how form bodies encode lists, seeInfusion.Runtime.Form:user_agent: theuser-agentheader:req_options: passed toReq.new/1as is, e.g.plug: {Req.Test, MyStub}:sleep: how to wait between retries,fn ms -> ... end(for tests)
Summary
Functions
Merges one layer into config.
Merges layers (keyword lists or maps) from left to right. Keys that are
not settings are ignored, so a call's options can be passed as a layer.
Types
@type t() :: %Infusion.Runtime.Config{ api_key: term(), auth: term(), base_url: term(), form_style: term(), headers: term(), idempotency_header: term(), max_retries: term(), req_options: term(), request_id_headers: term(), retry_count_header: term(), sleep: term(), timeout: term(), user_agent: term() }