diff --git a/.env.example b/.env.example index 32a1397..2383eb3 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,12 @@ LLM_ENDPOINT=http://localhost:11434/v1/chat/completions # Model name passed to the endpoint LLM_MODEL=llama3 -# Optional API key (sent as Bearer token) — leave blank for local servers +# Optional API key — value is sent as "Bearer ", do NOT include the word "Bearer" here LLM_API_KEY= +# Optional extra headers sent with every LLM request, as a JSON object +# Example: LLM_HEADERS={"x-openclaw-agent-id":"jibo"} +LLM_HEADERS= + # Default system prompt for the voice AI loop LLM_SYSTEM_PROMPT=You are Jibo, a friendly social robot. Keep responses brief and conversational. diff --git a/server.js b/server.js index b6236cd..a7ceb27 100644 --- a/server.js +++ b/server.js @@ -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 });