-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
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 cause400 Bad Requesterrors 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:
- Internal LLM gateways with strict schemas
- Lightweight or experimental model APIs
- Self-hosted endpoints that reject unknown fields