Repository navigation
feat(openai_api_compatible): support dynamic extra_headers model parameter - #3869
Souravrajvi0 wants to merge 6 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
|
Hi @Souravrajvi0, thanks for adding the dynamic Heads-up: #3832 also targets One more thing about Thanks again for your contributions! 🙏 |
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#}}