# `ALLM.Providers.Support.OpenAIHeaders`
[🔗](https://github.com/cykod/ALLM/blob/v0.3.0/lib/allm/providers/support/openai_headers.ex#L1)

Shared HTTP-header builder for OpenAI provider adapters. See spec §35.7
Decision #11.

Layer B helper. Both the chat adapter (`ALLM.Providers.OpenAI`) and the
image adapter (`ALLM.Providers.OpenAI.Images`) inject the same
`Authorization` and (optional) `openai-organization` headers; the only
difference is whether `content-type: application/json` is set explicitly
(`json_headers/2`) or elided so `Req`'s `:form_multipart` step can stamp
the multipart boundary itself (`multipart_headers/2`).

Both functions honor `opts[:adapter_opts][:organization]` per the
chat-adapter precedent at `lib/allm/providers/openai.ex:443-446` —
callers wishing to scope a request to an OpenAI org pass
`adapter_opts: [organization: "org-..."]` in their `opts` keyword list.

## Examples

    iex> ALLM.Providers.Support.OpenAIHeaders.json_headers("sk-test", [])
    [{"authorization", "Bearer sk-test"}, {"content-type", "application/json"}]

    iex> ALLM.Providers.Support.OpenAIHeaders.multipart_headers("sk-test", [])
    [{"authorization", "Bearer sk-test"}]

    iex> opts = [adapter_opts: [organization: "org-abc"]]
    iex> ALLM.Providers.Support.OpenAIHeaders.json_headers("sk-test", opts)
    [
      {"openai-organization", "org-abc"},
      {"authorization", "Bearer sk-test"},
      {"content-type", "application/json"}
    ]

    iex> opts = [adapter_opts: [organization: "org-abc"]]
    iex> ALLM.Providers.Support.OpenAIHeaders.multipart_headers("sk-test", opts)
    [{"openai-organization", "org-abc"}, {"authorization", "Bearer sk-test"}]

# `json_headers`

```elixir
@spec json_headers(api_key :: String.t(), opts :: keyword()) :: [
  {String.t(), String.t()}
]
```

Build headers for a JSON-bodied request. Returns
`[{"authorization", "Bearer <api_key>"}, {"content-type", "application/json"}, ...]`
optionally prefixed with `{"openai-organization", org}` when
`opts[:adapter_opts][:organization]` is a binary.

# `multipart_headers`

```elixir
@spec multipart_headers(api_key :: String.t(), opts :: keyword()) :: [
  {String.t(), String.t()}
]
```

Build headers for a multipart/form-data request. Returns
`[{"authorization", "Bearer <api_key>"}]` only — `content-type` is
intentionally elided so `Req`'s `:form_multipart` step stamps it with
the boundary string. Optionally prefixed with
`{"openai-organization", org}` when set.

---

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