Repository navigation
Description
Problem
providers.json allows a custom OpenAI-compatible provider to override request body fields via extra_body, but there is no way to add request headers. Several gateways require extra headers in addition to Authorization.
Concrete case: OpenCode Go (https://opencode.ai/zen/go/v1) rejects any request without an x-opencode-session header:
400 {'type': 'error', 'error': {'type': 'MissingSessionID', 'message': 'Request is missing x-opencode-session and cannot be routed efficiently. Please see https://opencode.ai/docs/go/#where-can-i-use-it'}}
Per https://opencode.ai/docs/go/ ("Where can I use it?"), non-OpenCode agents are explicitly allowed, but must send a stable x-opencode-session per conversation plus their own distinct User-Agent. There is currently no way to express this in providers.json, so --backend opencode-go fails even with a valid key.
Current workaround
The bundled openai SDK reads OPENAI_CUSTOM_HEADERS, so users can inject the header globally:
export OPENAI_CUSTOM_HEADERS="x-opencode-session: <uuid>
User-Agent: my-agent/1.0"This works (verified: graphify extract . --backend opencode-go --force succeeds, tokens reported), but it is global rather than per-provider and is not discoverable from the provider config.
Proposal
Allow an optional extra_headers map on a custom provider entry, mirroring extra_body:
{
"opencode-go": {
"base_url": "https://opencode.ai/zen/go/v1",
"default_model": "deepseek-v4-flash",
"env_key": "OPENCODE_API_KEY",
"extra_headers": {
"x-opencode-session": "<uuid>",
"User-Agent": "graphify/0.9.63"
}
}
}Pass it to the OpenAI client via default_headers at both client-construction sites:
_call_openai_compat— client built aroundllm.py:1389- the
--dedup-llmOpenAI-compatible path — client built aroundllm.py:3032
Ignore/drop an authorization entry for consistency with the SDK, which already refuses to let custom headers override an explicit API key.
Notes
extra_bodyis existing precedent for per-provider request customization; this is a small, symmetric addition.- Supporting a per-provider User-Agent would also help, since OpenCode Go asks clients to identify themselves rather than send a generic SDK UA.
Verified against graphifyy==0.9.63.
Activity
feat(llm): forward a custom provider's extra_headers as default_heade…
safishamsi commentedon Nov 9, 2026
Fixed in 0.9.105 (now on PyPI) via #4783: a custom OpenAI-compatible provider's extra_headers are now forwarded as default_headers (Authorization dropped).