[Feature] Support custom HTTP headers for OpenAI-compatible services
Is there an existing issue for this?
- I have searched the existing issues
Environment
Is there an existing issue for this?
- I have searched the existing issues.
Environment
- OS: macOS
- Zotero Version: 10.0.4
- Plugin Version: 2.4.7
Describe the feature request
Is your feature request related to a problem? Please describe.
I am using an OpenAI-compatible API that requires an additional HTTP request header.
For example, OpenCode Go requires the following header:
x-opencode-session: zotero-pdf-translateCurrently, the plugin supports custom request parameters, but these parameters are added to the JSON request body rather than to the HTTP headers.
For example, configuring:
Parameter Name: x-opencode-session
Parameter Value: "zotero-pdf-translate"results in a request body similar to:
{
"model": "...",
"messages": [...],
"x-opencode-session": "zotero-pdf-translate"
}However, the API requires:
x-opencode-session: zotero-pdf-translateas an HTTP header.
From the current implementation in src/modules/services/gpt.ts, the request headers appear to be fixed to values such as:
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${data.secret}`,
"api-key": data.secret,
}while custom request parameters are merged into the request body.
Therefore, APIs that require additional HTTP headers cannot currently be configured through the plugin UI.
Why do you need this feature?
Many OpenAI-compatible API providers require provider-specific HTTP headers in addition to Authorization.
OpenCode Go is one example, where x-opencode-session is required. A generic custom-header option would also improve compatibility with other OpenAI-compatible services without requiring provider-specific code.
Describe the solution you'd like
It would be useful to add a "Custom HTTP Headers" option for ChatGPT / Custom GPT services, similar to the existing "Custom Request Parameters" option.
For example, the UI could allow entries such as:
Header Name: x-opencode-session
Header Value: zotero-pdf-translateor alternatively accept a JSON object:
{
"x-opencode-session": "zotero-pdf-translate"
}These values could then be merged into the existing headers object when calling Zotero.HTTP.request().
Ideally, custom headers should be supported independently from custom request-body parameters.
Alternatives you've considered
A local proxy can be used to inject the required HTTP header before
Describe the feature request
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Why do you need this feature? A clear and concise description of why you need this feature.
Describe the solution you'd like
The solution you'd like A clear and concise description of what you want to happen.
Alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Anything else?
No response
Source: windingwind/zotero-pdf-translate