You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature Request]: plugin hook allowing modification of request body before it is sent #2661
Is your feature request related to a problem? Please describe.
When integrating custom model providers with opencode, some APIs do not support optional fields like "functions": {} or "images": [] in the request payload. These fields, while valid for certain providers (e.g., OpenAI or Anthropic), may cause 400 Bad Request errors when sent to stricter or minimalistic endpoints. Currently, opencode automatically includes these fields based on internal logic, and users have no way to override or customize the payload structure.
Describe the solution you'd like
I propose introducing a configuration option that allows users to define a custom request payload template—either via a JSON schema, a templating system, or a declarative list of enabled/disabled fields. This would give users full control over the shape of the outgoing request, ensuring compatibility with diverse model APIs. Ideally, this could be set per model provider or per model name.
Describe alternatives you've considered
Manually modifying the source code to remove unsupported fields (not scalable across upgrades)
Using a proxy server to rewrite requests before forwarding (adds complexity and latency)
Relying on the provider to ignore unknown fields (not always possible)
Additional context
This feature would greatly improve opencode’s flexibility when working with:
We have a plugin system we should just add addition hooks / expanding existing if current ones dont suffice and that would allow you to manipulate things before requests are sent
We have a plugin system we should just add addition hooks / expanding existing if current ones dont suffice and that would allow you to manipulate things before requests are sent
Fine. I see that plugin doc., but how to create a request body decorator plugin? That doc in your website is too crude.
changed the title [-]Feature Request: Allow Customizable Request Payload Templates for Model Compatibility[/-][+][Feature Request]: plugin hook allowing modification of request body before it is sent[/+]on Sep 23, 2025
Activity
github-actions commentedon Sep 18, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
rekram1-node commentedon Sep 18, 2025
We have a plugin system we should just add addition hooks / expanding existing if current ones dont suffice and that would allow you to manipulate things before requests are sent
Zim-Inn commentedon Sep 18, 2025
Fine. I see that
plugindoc., but how to create a request body decorator plugin? That doc in your website is too crude.rekram1-node commentedon Sep 18, 2025
Sorry I was just kinda saying how support for this would work didn't mean to sound dismissive of your ask.
Would something like the following work for you:
ability to intercept request bodies to the LLM provider before they are sent and edit them and then the edited version be sent to server?
Zim-Inn commentedon Sep 19, 2025
Yes, it is what I need.
BTW, you are so polite.
rekram1-node commentedon Sep 19, 2025
Happy to help, perfect yeah that sounds like something we can do for you
[-]Feature Request: Allow Customizable Request Payload Templates for Model Compatibility[/-][+][Feature Request]: plugin hook allowing modification of request body before it is sent[/+]NightRare commentedon Nov 27, 2025
Just wondering is there any update on this one? @rekram1-node thanks