Using LangChain with Typescript and working with google-genai, I want to use initChatModel so that I can have support for other model providers. My GOOGLE_API_KEY requires a specific referer http header to be set. I have not been able to find documentation or solutions through AI on how to properly do this.
With google’s genai library I do this to set it when creating the client:
new GoogleGenAI({
apiKey,
httpOptions: { headers: { referer }, timeout: 600000 },
});
I’ve tried a lot of different combinations with LangChain using initChatModel but nothing seems to work. Here is my latest attempt:
await initChatModel(modelName, {
thinkingConfig: { thinkingBudget: this.thinkingBudget },
clientOptions: {
httpOptions: {
headers: { referer: this.referer },
},
},
})
Does anyone know if there is a way to do this?