# `Tinkex.Env`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/env.ex#L1)

Centralized environment variable access for Tinkex.

## Naming Convention
- `TINKER_*` variables: Shared with Python SDK for cross-language compatibility
- `TINKEX_*` variables: Elixir-specific features (pool config, debug tools)
- `CLOUDFLARE_*` variables: Third-party service credentials

Normalizes values, applies defaults, and provides helpers for redaction so
callers avoid scattered `System.get_env/1` usage.

# `env_source`

```elixir
@type env_source() :: :system | %{optional(String.t()) =&gt; String.t()}
```

# `api_key`

```elixir
@spec api_key(env_source()) :: String.t() | nil
```

# `base_url`

```elixir
@spec base_url(env_source()) :: String.t() | nil
```

# `cf_access_client_id`

```elixir
@spec cf_access_client_id(env_source()) :: String.t() | nil
```

# `cf_access_client_secret`

```elixir
@spec cf_access_client_secret(env_source()) :: String.t() | nil
```

# `default_headers`

```elixir
@spec default_headers(env_source()) :: map()
```

Get default headers map from environment.

Set `TINKEX_DEFAULT_HEADERS` to a JSON object of header name/value pairs.

# `default_query`

```elixir
@spec default_query(env_source()) :: map()
```

Get default query params map from environment.

Set `TINKEX_DEFAULT_QUERY` to a JSON object of query name/value pairs.

# `dump_headers?`

```elixir
@spec dump_headers?(env_source()) :: boolean()
```

# `feature_gates`

```elixir
@spec feature_gates(env_source()) :: [String.t()]
```

# `hf_home`

```elixir
@spec hf_home(env_source()) :: String.t()
```

Get Hugging Face home directory from environment.

# `hf_token`

```elixir
@spec hf_token(env_source()) :: String.t() | nil
```

Get Hugging Face token from environment.

Honors `HF_TOKEN` first, then `HUGGING_FACE_HUB_TOKEN`.

# `hf_token_path`

```elixir
@spec hf_token_path(env_source()) :: String.t()
```

Get Hugging Face token path from environment.

# `http_client`

```elixir
@spec http_client(env_source()) :: module() | nil
```

Get custom HTTP client module from environment.

Set `TINKEX_HTTP_CLIENT` to a module name (e.g., `Tinkex.API`).

# `http_pool`

```elixir
@spec http_pool(env_source()) :: atom() | nil
```

Get HTTP pool name from environment.

Set `TINKEX_HTTP_POOL` to an atom name (e.g., `Tinkex.HTTP.Pool`).

# `log_level`

```elixir
@spec log_level(env_source()) :: :debug | :info | :warn | :error | nil
```

# `mask_secret`

```elixir
@spec mask_secret(term()) :: term()
```

Replace a secret with a constant marker.

# `otel_propagate`

```elixir
@spec otel_propagate(env_source()) :: boolean()
```

Get OpenTelemetry propagation setting from environment.

Set `TINKEX_OTEL_PROPAGATE=true` to enable W3C Trace Context propagation.
When enabled, outgoing requests will carry traceparent/tracestate headers.

# `parity_mode`

```elixir
@spec parity_mode(env_source()) :: :python | :beam | nil
```

Get parity mode from environment.

Defaults to Python parity. Set `TINKEX_PARITY=beam` to use BEAM-conservative
defaults (`timeout: 120_000`, `max_retries: 2`), or `TINKEX_PARITY=python` to
explicitly select Python SDK defaults (`timeout: 60_000`, `max_retries: 10`).

# `poll_backoff`

```elixir
@spec poll_backoff(env_source()) :: :exponential | nil
```

Get future polling backoff policy from environment.

Set `TINKEX_POLL_BACKOFF=exponential` (or truthy value) to enable backoff
for 408/5xx polling retries. Use `TINKEX_POLL_BACKOFF=0` to disable.

# `pool_count`

```elixir
@spec pool_count(env_source()) :: pos_integer() | nil
```

Get HTTP pool count from environment.

Set `TINKEX_POOL_COUNT` to override the number of connection pools.

# `pool_size`

```elixir
@spec pool_size(env_source()) :: pos_integer() | nil
```

Get HTTP pool size from environment.

Python SDK uses `max_connections=1000` by default.
Set `TINKEX_POOL_SIZE` to override.

# `proxy`

```elixir
@spec proxy(env_source()) :: String.t() | nil
```

Get proxy configuration from environment.

Set `TINKEX_PROXY` to a URL string like "http://proxy.example.com:8080"
or "http://user:pass@proxy.example.com:8080".

# `proxy_headers`

```elixir
@spec proxy_headers(env_source()) :: [{String.t(), String.t()}]
```

Get proxy headers from environment.

Set `TINKEX_PROXY_HEADERS` to a JSON array of {name, value} tuples.
Example: `TINKEX_PROXY_HEADERS='[["proxy-authorization", "Basic abc123"]]'`

# `redact`

```elixir
@spec redact(map()) :: map()
```

Redact secrets in a snapshot or map using simple replacement.

# `snapshot`

```elixir
@spec snapshot(env_source()) :: map()
```

Snapshot all known env-driven values in one map.

# `tags`

```elixir
@spec tags(env_source()) :: [String.t()]
```

# `telemetry_enabled?`

```elixir
@spec telemetry_enabled?(env_source()) :: boolean()
```

---

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