Skip to content

[FEATURE]: Support custom HTTP body fields in provider configuration #29592

@timxx

Description

@timxx

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

opencode supports adding custom HTTP headers to provider requests via provider..options.headers in the config. This is useful for API gateways, proxies, and providers that require additional authentication or routing metadata.

However, there is no equivalent mechanism for injecting custom fields into the HTTP request body.
For our internal gateway, it requires to pass extra body to make the response work correctly, currently isn't possible.

Proposed solution

Add a body option under the provider options config, parallel to the existing headers option:
// opencode.json

{
    "provider": {
        "my-provider": {
            "options": {
                "baseURL": "https://my-api.example.com/v1",
                "headers": {
                    "X-Custom-Auth": "token-123"
                },
                "body": {
                    "custom_routing": "fast",
                    "metadata": {
                        "source": "opencode"
                    }
                }
            }
        }
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions