# `Infusion.Runtime.Config`
[🔗](https://github.com/mandar1045/infusion/blob/v0.1.0/runtime/lib/infusion/runtime/config.ex#L1)

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"}`, or `nil`
  * `: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, see `Infusion.Runtime.Form`
  * `:user_agent`: the `user-agent` header
  * `:req_options`: passed to `Req.new/1` as is, e.g. `plug: {Req.Test, MyStub}`
  * `:sleep`: how to wait between retries, `fn ms -> ... end` (for tests)

# `t`

```elixir
@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()
}
```

# `merge`

```elixir
@spec merge(t(), keyword() | map() | nil) :: t()
```

Merges one layer into `config`.

# `new`

```elixir
@spec new([keyword() | map()]) :: t()
```

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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
