mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/Re-Commander.git
synced 2026-06-15 09:26:10 +00:00
Add LLM_HEADERS support for custom request headers
Reads LLM_HEADERS as a JSON object from .env and merges it into every LLM request alongside the existing Authorization header. Useful for endpoints that require non-standard headers (e.g. x-openclaw-agent-id). LLM_API_KEY continues to be sent without the "Bearer" prefix in .env. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -922,6 +922,10 @@ app.post('/api/llm/chat', async (req, res) => {
|
||||
|
||||
const headers = {};
|
||||
if (apiKey) headers['Authorization'] = `Bearer ${apiKey}`;
|
||||
try {
|
||||
const extra = process.env.LLM_HEADERS ? JSON.parse(process.env.LLM_HEADERS) : {};
|
||||
Object.assign(headers, extra);
|
||||
} catch { console.warn('[llm] LLM_HEADERS is not valid JSON — ignored'); }
|
||||
|
||||
try {
|
||||
const result = await httpPost(url, headers, { model: mdl, messages: allMessages, stream: false });
|
||||
|
||||
Reference in New Issue
Block a user