Skip to content

feat(embed): add default_headers support to OpenAIEmbeddingConfig#703

Closed
micmarty-deepsense wants to merge 1 commit intomainfrom
mike/uni-57-custom-openai-compatible-embedder
Closed

feat(embed): add default_headers support to OpenAIEmbeddingConfig#703
micmarty-deepsense wants to merge 1 commit intomainfrom
mike/uni-57-custom-openai-compatible-embedder

Conversation

@micmarty-deepsense
Copy link
Copy Markdown
Contributor

@micmarty-deepsense micmarty-deepsense commented May 5, 2026

What changes

unstructured_ingest/embed/openai.py

  • Adds default_headers: Optional[dict[str, SecretStr]] to OpenAIEmbeddingConfig
  • In get_client() and get_async_client(): extracts header values via .get_secret_value() and passes default_headers= to the OpenAI SDK constructor
  • Uses explicit dict comprehension (not model_dump) to avoid SecretStr serialization to "**********"

The OpenAI SDK's default_headers constructor param attaches extra headers to every request without interfering with Bearer token construction. This enables custom OpenAI-compatible endpoints that require additional auth headers.

Test plan

  • Unit test: verify get_client() passes extracted headers when default_headers is set
  • Unit test: verify get_client() omits default_headers kwarg when field is None
  • Manual: configure an embedder with default_headers pointing at a custom endpoint, confirm headers appear on requests

@micmarty-deepsense micmarty-deepsense changed the title [UNI-57 PoC] add default_headers to OpenAIEmbeddingConfig add default_headers to OpenAIEmbeddingConfig May 7, 2026
@micmarty-deepsense micmarty-deepsense force-pushed the mike/uni-57-custom-openai-compatible-embedder branch from 37e2ace to 9a4ca02 Compare May 7, 2026 11:58
@micmarty-deepsense micmarty-deepsense changed the title add default_headers to OpenAIEmbeddingConfig feat(embed): add default_headers support to OpenAIEmbeddingConfig May 7, 2026
@micmarty-deepsense micmarty-deepsense force-pushed the mike/uni-57-custom-openai-compatible-embedder branch from 9a4ca02 to bb0a84a Compare May 7, 2026 11:59
Adds an optional default_headers: dict[str, SecretStr] field to
OpenAIEmbeddingConfig. When set, the headers are extracted via
.get_secret_value() and passed as default_headers= to the OpenAI
SDK constructor, attaching them to every request.

This enables custom OpenAI-compatible endpoints that require
non-standard auth headers alongside the Bearer token.
@micmarty-deepsense
Copy link
Copy Markdown
Contributor Author

Closing in favour of a new PR from a clean branch. All changes preserved — see replacement PR.

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.

1 participant