Skip to content

feat(embedder): support extra HTTP headers for OpenAI-compatible providers#694

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
Astro-Han:feature/extra-headers-embedding
Mar 17, 2026
Merged

feat(embedder): support extra HTTP headers for OpenAI-compatible providers#694
qin-ctx merged 1 commit intovolcengine:mainfrom
Astro-Han:feature/extra-headers-embedding

Conversation

@Astro-Han
Copy link
Contributor

Summary

Add extra_headers support to EmbeddingModelConfig and OpenAIDenseEmbedder, enabling custom HTTP headers (e.g., HTTP-Referer, X-Title required by OpenRouter) to be passed as default_headers to the OpenAI client.

Also fix a dead-code bug where an unconditional raise ValueError("api_key is required") prevented the more nuanced check that allows missing api_key when api_base is set (e.g., local OpenAI-compatible servers).

Type of Change

  • New feature (feat)
  • Bug fix (fix)

Testing

  • Unit tests pass (8 new tests covering direct construction, factory path, config validation, and api_key fix)
  • Existing tests unaffected
  • Ruff lint passes

Related Issues

Checklist

  • Code follows project style guidelines
  • Tests added for new functionality
  • All tests pass

…iders

Add `extra_headers` field to `EmbeddingModelConfig` and `OpenAIDenseEmbedder`,
enabling custom HTTP headers (e.g., `HTTP-Referer`, `X-Title` required by
OpenRouter) to be passed as `default_headers` to the OpenAI client.

Also fix a dead-code bug in `OpenAIDenseEmbedder.__init__` where an
unconditional `raise ValueError("api_key is required")` prevented the
more nuanced check that allows missing `api_key` when `api_base` is set
(e.g., local OpenAI-compatible servers).

Closes volcengine#675
@CLAassistant
Copy link

CLAassistant commented Mar 17, 2026

CLA assistant check
All committers have signed the CLA.

@qin-ctx qin-ctx merged commit de6cf27 into volcengine:main Mar 17, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Support OpenRouter Embeddings API

3 participants