Skip to content

feat: add extra_headers support to all client methods#193

Merged
Kamilbenkirane merged 3 commits intomainfrom
feat/extra-headers
Feb 25, 2026
Merged

feat: add extra_headers support to all client methods#193
Kamilbenkirane merged 3 commits intomainfrom
feat/extra-headers

Conversation

@Kamilbenkirane
Copy link
Member

Summary

  • Adds extra_headers: dict[str, str] | None = None alongside extra_body on all client methods (generate, stream, analyze, speak, embed, edit)
  • Extends _json_headers() to accept and merge user headers for the common case (~28 call sites)
  • Keeps _merge_headers() static helper for edge cases that bypass _json_headers (WebSocket, multipart, custom poll headers)
  • Anthropic's _build_headers() accepts extra_headers and applies it last so user headers win over version + beta headers
  • Updates all 3 templates (provider, protocol, modality) and adds extra_headers validation to the template contract test

Usage

response = await celeste.text.generate(
    "Analyze this massive codebase...",
    model="claude-sonnet-4-6",
    extra_headers={"anthropic-beta": "context-1m-2025-08-07"},
)

Test plan

  • All 497 unit tests pass
  • mypy clean on 298 source files
  • All pre-commit hooks pass (ruff lint, ruff format, mypy, bandit, tests)
  • Template contract test validates extra_headers param on all provider API clients

Closes #178

Add `extra_headers: dict[str, str] | None = None` alongside `extra_body`
on all client methods, enabling users to pass provider-specific HTTP
headers (e.g., Anthropic's 1M context beta header).

- Extend `_json_headers()` to accept and merge extra headers
- Add `_merge_headers()` static helper for edge cases (WebSocket, multipart)
- Thread `extra_headers` through `_predict()` → `_make_request()` and
  `_stream()` → `_make_stream_request()` across all providers
- Update all 3 templates and the template contract test

Closes #178

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Feb 25, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Kamilbenkirane and others added 2 commits February 25, 2026 16:47
- Make _merge_headers return a new dict instead of mutating input
- Add extra_headers to base _make_stream_request stub signature
- Fix OpenAI videos multipart sending wrong Content-Type
- Add extra_headers to Google _get_interaction and download_content
- Simplify BFL header construction to use _json_headers(extra_headers)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Kamilbenkirane Kamilbenkirane merged commit 10133e6 into main Feb 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add extra_headers support to all client methods

1 participant