Skip to content

feat(openai_api_compatible): support dynamic extra_headers model parameter - #3869

Open
Souravrajvi0 wants to merge 6 commits into
langgenius:mainfrom
Souravrajvi0:feat/openai-compat-extra-headers-069c
Open

Souravrajvi0 wants to merge 6 commits into
langgenius:mainfrom
Souravrajvi0:feat/openai-compat-extra-headers-069c

Conversation

@Souravrajvi0

@Souravrajvi0 Souravrajvi0 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #3865

Adds an extra_headers model 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

  • Expose extra_headers (JSON string) in the LLM model parameter schema
  • Parse and merge model-parameter headers with any credential-level extra_headers
  • Forward merged headers on both Chat Completions (requests) and Responses API (OpenAI client) paths
  • Add regression tests (8 passing)

Test plan

  • uv run pytest models/openai_api_compatible/tests/test_extra_headers.py
  • Configure OpenAI API Compatible model with extra_headers using {{#sys.conversation_id#}}

…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
@crazywoola
crazywoola had a problem deploying to models/openai_api_compatible September 11, 2026 14:24 — with GitHub Actions Failure
@crazywoola
crazywoola self-requested a review September 12, 2026 03:28
@crazywoola
crazywoola had a problem deploying to models/openai_api_compatible September 14, 2026 01:30 — with GitHub Actions Failure
@crazywoola
crazywoola self-requested a review September 15, 2026 02:47
@crazywoola

Copy link
Copy Markdown
Member

Hi @Souravrajvi0, thanks for adding the dynamic extra_headers model parameter!

Heads-up: #3832 also targets models/openai_api_compatible and was closed just now because it has merge conflicts with main. To keep the release queue clean, could you please fold the reasoning_effort forwarding change from #3832 into this PR if it's still needed, and reference its issue #3827 in the description alongside #3865?

One more thing about manifest.yaml: the consolidated dependency refresh (#4106–#4111) bumped models/openai_api_compatible to 0.0.69 on main, and there are several open PRs for this plugin from different authors (#3795, #4060, #4066, #4068, #4079). Please rebase on latest main, add the version bump, and use the next unused version so the releases don't collide.

Thanks again for your contributions! 🙏

This branch had an error being deployed

1 failed deployment
models/openai_api_compatible — c7c851cf Deployed Sep 20, 2026 by crazywoola via test (models/openai_api_compatible) #2761
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.

Feature Request: Reconsider dynamic custom request headers in OpenAI API Compatible provider — now required by OpenCode Go

2 participants