Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I would like to ask the team to reconsider, and if appropriate reopen, the previous request for supporting custom HTTP request headers in the OpenAI API Compatible provider.
Related issue: #3012
This has recently become more important because this is no longer only a customization or optimization use case.
OpenCode Go now requires clients to provide a stable session identifier for each conversation via the x-opencode-session request header. Requests without a session ID may fail, and users are already reporting HTTP 400 MissingSessionID errors.
This means that, for Dify users who want to use OpenCode Go through the OpenAI API Compatible provider, dynamic custom headers are effectively required for the integration to work correctly.
OpenCode Go requirement
OpenCode Go's documentation requires clients to send a stable session ID for every conversation:
x-opencode-session: <stable-session-id>
The session ID must remain stable for all requests belonging to the same conversation.
This is used by OpenCode Go for:
- session-aware routing
- provider affinity
- prompt caching
- request optimization
OpenCode Go has also started enforcing this requirement. Requests without the session header can now fail with an error such as:
400 MissingSessionID
Request is missing x-opencode-session and cannot be routed efficiently.
Therefore, this is no longer simply a request to support arbitrary vendor-specific metadata.
For OpenCode Go, the lack of dynamic request-header support can make the Dify OpenAI API Compatible provider unusable.
Dify already has the ideal session identifier
Dify already provides:
{{#sys.conversation_id#}}
This value is exactly what is needed for this use case:
Dify Conversation A
↓
sys.conversation_id = abc-123
↓
x-opencode-session: abc-123
Next message in Conversation A
↓
x-opencode-session: abc-123
New Conversation B
↓
sys.conversation_id = def-456
↓
x-opencode-session: def-456
So ideally, the OpenAI API Compatible provider could expose a model parameter such as:
- name: extra_headers
type: string
required: false
label:
en_US: Extra Headers
Then the LLM node could configure:
{
"x-opencode-session": "{{#sys.conversation_id#}}"
}
and Dify would send:
POST /v1/chat/completions
Authorization: Bearer ...
Content-Type: application/json
x-opencode-session: abc-123
Why dynamic headers are important
A static extra_headers configuration would not fully solve this problem.
For OpenCode Go, this would be incorrect:
{
"x-opencode-session": "one-global-static-id"
}
because unrelated Dify conversations would all appear as the same OpenCode session.
What is needed is the ability to resolve Dify variables at invocation time:
{
"x-opencode-session": "{{#sys.conversation_id#}}"
}
This allows each Dify conversation to have its own stable session ID.
This is also useful beyond OpenCode Go
Although OpenCode Go is now a concrete case where this functionality is required, generic dynamic request headers would also support many other OpenAI-compatible services that use headers for:
- session affinity
- distributed tracing
- request routing
- tenant identification
- gateway metadata
- cache affinity
- vendor-specific OpenAI-compatible extensions
So I believe supporting this generically in the OpenAI API Compatible provider would be preferable to adding OpenCode-specific logic.
2. Additional context or comments
Current workarounds
Without this functionality, Dify users currently need to:
- fork and modify the OpenAI API Compatible provider plugin,
- implement a custom provider plugin,
- put a custom reverse proxy between Dify and OpenCode Go, or
- stop using the LLM node and manually invoke the API through an HTTP Request node.
These are significant workarounds for an API that is otherwise OpenAI-compatible.
In particular, using an HTTP Request node means losing much of the functionality normally provided by the Dify LLM node.
Why this may be worth reconsidering now
My understanding is that newer Dify versions already support resolving workflow/system variables in string-type model parameters.
Therefore, Dify now appears to have most of the infrastructure required for this use case.
The missing piece is allowing the OpenAI API Compatible provider to expose an extra_headers (or equivalent) parameter and forward those resolved headers to the underlying OpenAI-compatible request.
Conceptually:
Dify LLM Node
│
│ {{#sys.conversation_id#}}
▼
extra_headers
│
▼
OpenAI API Compatible Provider
│
│ x-opencode-session: <conversation_id>
▼
OpenCode Go
Requested behavior
It would be great if the OpenAI API Compatible provider could support something like:
Extra Headers:
{
"x-opencode-session": "{{#sys.conversation_id#}}"
}
with Dify resolving the variable for each LLM invocation before passing the headers to the provider.
Why I am asking to reconsider #3012
I understand that the previous custom-header request was closed as not planned.
However, I believe the situation has materially changed:
- Dify now has support for resolving variables in model parameters.
- OpenCode Go now requires a stable per-conversation session header.
- Missing this header can cause actual API requests to fail with HTTP 400 errors.
- Dify already has
sys.conversation_id, which maps naturally to this requirement.
- The inability to dynamically set this header prevents an otherwise OpenAI-compatible API from being used normally through Dify's LLM node.
For these reasons, could the team please reconsider supporting dynamic custom HTTP headers in the OpenAI API Compatible provider, or reopen #3012 for further discussion?
Thank you!
3. Can you help us with this feature?
Self Checks
1. Is this request related to a challenge you're experiencing? Tell me about your story.
I would like to ask the team to reconsider, and if appropriate reopen, the previous request for supporting custom HTTP request headers in the OpenAI API Compatible provider.
Related issue: #3012
This has recently become more important because this is no longer only a customization or optimization use case.
OpenCode Go now requires clients to provide a stable session identifier for each conversation via the
x-opencode-sessionrequest header. Requests without a session ID may fail, and users are already reporting HTTP 400MissingSessionIDerrors.This means that, for Dify users who want to use OpenCode Go through the OpenAI API Compatible provider, dynamic custom headers are effectively required for the integration to work correctly.
OpenCode Go requirement
OpenCode Go's documentation requires clients to send a stable session ID for every conversation:
x-opencode-session: <stable-session-id>The session ID must remain stable for all requests belonging to the same conversation.
This is used by OpenCode Go for:
OpenCode Go has also started enforcing this requirement. Requests without the session header can now fail with an error such as:
Therefore, this is no longer simply a request to support arbitrary vendor-specific metadata.
For OpenCode Go, the lack of dynamic request-header support can make the Dify OpenAI API Compatible provider unusable.
Dify already has the ideal session identifier
Dify already provides:
This value is exactly what is needed for this use case:
So ideally, the OpenAI API Compatible provider could expose a model parameter such as:
Then the LLM node could configure:
{ "x-opencode-session": "{{#sys.conversation_id#}}" }and Dify would send:
Why dynamic headers are important
A static
extra_headersconfiguration would not fully solve this problem.For OpenCode Go, this would be incorrect:
{ "x-opencode-session": "one-global-static-id" }because unrelated Dify conversations would all appear as the same OpenCode session.
What is needed is the ability to resolve Dify variables at invocation time:
{ "x-opencode-session": "{{#sys.conversation_id#}}" }This allows each Dify conversation to have its own stable session ID.
This is also useful beyond OpenCode Go
Although OpenCode Go is now a concrete case where this functionality is required, generic dynamic request headers would also support many other OpenAI-compatible services that use headers for:
So I believe supporting this generically in the OpenAI API Compatible provider would be preferable to adding OpenCode-specific logic.
2. Additional context or comments
Current workarounds
Without this functionality, Dify users currently need to:
These are significant workarounds for an API that is otherwise OpenAI-compatible.
In particular, using an HTTP Request node means losing much of the functionality normally provided by the Dify LLM node.
Why this may be worth reconsidering now
My understanding is that newer Dify versions already support resolving workflow/system variables in string-type model parameters.
Therefore, Dify now appears to have most of the infrastructure required for this use case.
The missing piece is allowing the OpenAI API Compatible provider to expose an
extra_headers(or equivalent) parameter and forward those resolved headers to the underlying OpenAI-compatible request.Conceptually:
Requested behavior
It would be great if the OpenAI API Compatible provider could support something like:
with Dify resolving the variable for each LLM invocation before passing the headers to the provider.
Why I am asking to reconsider #3012
I understand that the previous custom-header request was closed as not planned.
However, I believe the situation has materially changed:
sys.conversation_id, which maps naturally to this requirement.For these reasons, could the team please reconsider supporting dynamic custom HTTP headers in the OpenAI API Compatible provider, or reopen #3012 for further discussion?
Thank you!
3. Can you help us with this feature?