chore: change how headers affect

Signed-off-by: Zhiqiang ZHOU <im@strrl.dev>
This commit is contained in:
Zhiqiang ZHOU 2025-06-20 12:39:18 -07:00
parent 7a8a38ac6f
commit aa7775225a
No known key found for this signature in database
GPG Key ID: 445EC770299B03A8
2 changed files with 13 additions and 5 deletions

View File

@ -6,7 +6,7 @@
"api_key": "",
"metadata": {
"get_models_url": "https://openrouter.ai/api/v1/models",
"header_template": "Authorization: Bearer {{api_key}} HTTP-Referer: https://jan.ai X-Title: Jan",
"header_template": "Authorization: Bearer {{api_key}}",
"transform_req": {
"chat_completions": {
"url": "https://openrouter.ai/api/v1/chat/completions",

View File

@ -129,6 +129,14 @@ export const sendCompletion = async (
apiKey: provider.api_key ?? (await invoke('app_token')),
// TODO: Retrieve from extension settings
baseURL: provider.base_url,
// OpenRouter identification headers for Jan
// ref: https://openrouter.ai/docs/api-reference/overview#headers
...(provider.provider === 'openrouter' && {
defaultHeaders: {
'HTTP-Referer': 'https://jan.ai',
'X-Title': 'Jan',
},
}),
})
if (
thread.model.id &&
@ -277,10 +285,10 @@ export const extractToolCall = (
* @param calls
* @param builder
* @param message
* @param content
* @param approvedTools - Record of approved tools per thread
* @param showModal - Function to show approval modal, returns true if approved
* @param allowAllMCPPermissions - Global setting to allow all MCP permissions without modal
* @param abortController
* @param approvedTools
* @param showModal
* @param allowAllMCPPermissions
*/
export const postMessageProcessing = async (
calls: ChatCompletionMessageToolCall[],