Summary
The same 3-line header dict construction appears 8 times across 4 provider/protocol client files.
Current Code (repeated 8 times)
headers = {
**self.auth.get_headers(),
"Content-Type": ApplicationMimeType.JSON,
}
Proposed Change
Add a one-line helper to APIMixin:
def _json_headers(self) -> dict[str, str]:
"""Build standard JSON request headers with auth."""
return {**self.auth.get_headers(), "Content-Type": ApplicationMimeType.JSON}
Each call site becomes headers = self._json_headers(). Anthropic, which adds extra headers (anthropic-version, beta), composes naturally: headers = {**self._json_headers(), config.HEADER_ANTHROPIC_VERSION: ...}.
Files to Modify
src/celeste/client.py (APIMixin - add method)
src/celeste/protocols/chatcompletions/client.py (2 call sites)
src/celeste/protocols/openresponses/client.py (2 call sites)
src/celeste/providers/cohere/chat/client.py (2 call sites)
src/celeste/providers/google/generate_content/client.py (2 call sites)
Rationale
8 identical 3-line constructions reduced to 8 one-line calls. The helper is trivially simple, adds no indirection complexity, and follows the existing _deep_merge utility pattern already on APIMixin.
Summary
The same 3-line header dict construction appears 8 times across 4 provider/protocol client files.
Current Code (repeated 8 times)
Proposed Change
Add a one-line helper to
APIMixin:Each call site becomes
headers = self._json_headers(). Anthropic, which adds extra headers (anthropic-version, beta), composes naturally:headers = {**self._json_headers(), config.HEADER_ANTHROPIC_VERSION: ...}.Files to Modify
src/celeste/client.py(APIMixin - add method)src/celeste/protocols/chatcompletions/client.py(2 call sites)src/celeste/protocols/openresponses/client.py(2 call sites)src/celeste/providers/cohere/chat/client.py(2 call sites)src/celeste/providers/google/generate_content/client.py(2 call sites)Rationale
8 identical 3-line constructions reduced to 8 one-line calls. The helper is trivially simple, adds no indirection complexity, and follows the existing
_deep_mergeutility pattern already on APIMixin.