Skip to content

feat: Add extra_headers support to all client methods #178

Description

@Kamilbenkirane

Problem

Celeste provides extra_body as an escape hatch for provider-specific request body fields, but there's no equivalent for HTTP headers. This gap is felt today with Anthropic's 1M context window, which requires a beta header (anthropic-beta: context-1m-2025-08-07) and has premium pricing — making it something users must explicitly opt into.

Currently, the only way to influence headers is through the internal _beta_features convention, which is undocumented and fragile.

Proposal

Add extra_headers: dict[str, str] | None = None alongside extra_body on all client methods (generate, stream, analyze, speak, embed, edit).

User-facing API:

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

Scope

  • Add extra_headers parameter to _predict(), _stream() in base ModalityClient
  • Thread it through all namespace methods (text, images, audio, videos, embeddings)
  • Merge with provider-built headers in _make_request() / _make_stream_request() (user headers take precedence)
  • Apply to both public and private repos

Precedent

OpenAI's Python SDK offers extra_headers, extra_body, and extra_query on every request method. This is an established pattern for provider-agnostic SDKs.

Why not a dedicated parameter?

A context_window="1m" parameter would pollute the unified interface for a single provider's beta feature. extra_headers keeps provider-specific concerns where they belong — in the escape hatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions