feat(openai_api_compatible): support dynamic extra_headers model parameter - #3869
Open
Souravrajvi0 wants to merge 4 commits into
Open
feat(openai_api_compatible): support dynamic extra_headers model parameter#3869Souravrajvi0 wants to merge 4 commits into
Souravrajvi0 wants to merge 4 commits into
Conversation
…meter Expose an extra_headers JSON model parameter on the OpenAI API Compatible LLM provider so callers can send per-invocation HTTP headers with resolved Dify variables (e.g. x-opencode-session from sys.conversation_id). Merges model-parameter headers with any credential-level extra_headers and forwards them to both Chat Completions and Responses API request paths. Fixes langgenius#3865
5 tasks
crazywoola
approved these changes
Sep 11, 2026
crazywoola
had a problem deploying
to
models/openai_api_compatible
September 11, 2026 14:24 — with
GitHub Actions
Failure
crazywoola
self-requested a review
September 12, 2026 03:28
crazywoola
approved these changes
Sep 14, 2026
crazywoola
had a problem deploying
to
models/openai_api_compatible
September 14, 2026 01:30 — with
GitHub Actions
Failure
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.
Summary
Fixes #3865
Adds an
extra_headersmodel parameter to the OpenAI API Compatible LLM provider so callers can send per-invocation HTTP headers with Dify-resolved variables.Use case
OpenCode Go requires a stable session header per conversation:
{ "x-opencode-session": "{{#sys.conversation_id#}}" }Dify resolves workflow/system variables in model parameters at invocation time; this change forwards the resolved headers to the underlying OpenAI-compatible request.
Changes
extra_headers(JSON string) in the LLM model parameter schemaextra_headersrequests) and Responses API (OpenAIclient) pathsTest plan
uv run pytest models/openai_api_compatible/tests/test_extra_headers.pyextra_headersusing{{#sys.conversation_id#}}