feat: add http_headers support to LlmProvider for custom upstream headers#870
Open
octo-patch wants to merge 1 commit intokatanemo:mainfrom
Open
feat: add http_headers support to LlmProvider for custom upstream headers#870octo-patch wants to merge 1 commit intokatanemo:mainfrom
octo-patch wants to merge 1 commit intokatanemo:mainfrom
Conversation
…ders (fixes katanemo#592) Allows users to specify custom HTTP request headers per LLM provider in plano_config.yaml, useful for providers requiring non-standard auth or telemetry headers: model_providers: - model: provider/model access_key: $API_KEY http_headers: X-Custom-Header: "custom-value" X-API-Version: "v1"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #592
Problem
LlmProvidersupports customendpointandaccess_keybut has no way to pass custom HTTP request headers to the upstream provider. Some providers or API gateways require non-standard headers for authentication (e.g.,X-API-Key,X-Org-ID) or telemetry purposes that cannot be expressed through the existingaccess_keyfield.Solution
Added an optional
http_headersfield toLlmProviderthat accepts a key-value map of HTTP headers to be injected into every upstream request for that provider:Changes:
crates/common/src/configuration.rs: Addedhttp_headers: Option<HashMap<String, String>>field toLlmProviderstructcrates/common/src/llm_providers.rs: Updatedcreate_test_providertest helper to include the new fieldcrates/llm_gateway/src/stream_context.rs: Addedset_custom_provider_headers()method that applies configured headers after auth headers are set; called fromon_http_request_headersconfig/plano_config_schema.yaml: Addedhttp_headersto the schema for bothmodel_providersand the deprecatedllm_providerssectionsCustom headers are applied after provider-specific auth headers (Authorization, x-api-key), so they can supplement but not accidentally override authentication.
Testing
The change is backward compatible — the new field is
Option<...>and defaults toNone, so existing configs are unaffected. The schema addition ensures validation passes for configs using the new field.