@@ -16,11 +16,10 @@ import { isLocalInferenceEnabled } from './ollama/config.js';
1616import { isOllamaAvailable } from './ollama/OllamaService.js' ;
1717
1818/** 构建公共请求头(JSON 模式含 Content-Type,multipart 由 fetch 自动生成) */
19- function buildHeaders ( clientRequestId : string , json : boolean , authToken ?: string , userApiKey ?: string ) : Record < string , string > {
19+ function buildHeaders ( clientRequestId : string , json : boolean , authToken ?: string ) : Record < string , string > {
2020 const headers : Record < string , string > = { 'X-Request-ID' : clientRequestId } ;
2121 if ( json ) headers [ 'Content-Type' ] = 'application/json' ;
2222 if ( authToken ) headers [ 'Authorization' ] = `Bearer ${ authToken } ` ;
23- if ( userApiKey ) headers [ 'X-User-API-Key' ] = userApiKey ;
2423 return headers ;
2524}
2625
@@ -44,7 +43,6 @@ async function executePost<TRes>(
4443 isJson : boolean ,
4544 bodyDesc : string ,
4645 authToken ?: string ,
47- userApiKey ?: string ,
4846 timeoutMs : number = 60000 ,
4947) : Promise < { data : TRes ; requestId : string | undefined } > {
5048 const base = gatewayUrl ( ) ;
@@ -57,9 +55,9 @@ async function executePost<TRes>(
5755
5856 // ── 请求前日志 ──
5957 logger . info ( `[AI] → POST ${ url } [req-id: ${ clientRequestId } ]` ) ;
60- logger . debug ( `[AI] Request config: timeout=${ timeoutMs } ms, hasAuth=${ ! ! authToken } , hasUserKey= ${ ! ! userApiKey } , ${ bodyDesc } ` ) ;
58+ logger . debug ( `[AI] Request config: timeout=${ timeoutMs } ms, hasAuth=${ ! ! authToken } , ${ bodyDesc } ` ) ;
6159
62- const headers = buildHeaders ( clientRequestId , isJson , authToken , userApiKey ) ;
60+ const headers = buildHeaders ( clientRequestId , isJson , authToken ) ;
6361
6462 const controller = new AbortController ( ) ;
6563 const timeoutId = setTimeout ( ( ) => controller . abort ( ) , timeoutMs ) ;
@@ -122,11 +120,10 @@ export async function postJson<TReq, TRes>(
122120 apiPath : string ,
123121 body : TReq ,
124122 authToken ?: string ,
125- userApiKey ?: string ,
126123 timeoutMs : number = 60000 ,
127124) : Promise < { data : TRes ; requestId : string | undefined } > {
128125 const bodyDesc = `bodyKeys=${ Object . keys ( body as Record < string , unknown > ) . join ( ',' ) } ` ;
129- return executePost < TRes > ( apiPath , JSON . stringify ( body ) , true , bodyDesc , authToken , userApiKey , timeoutMs ) ;
126+ return executePost < TRes > ( apiPath , JSON . stringify ( body ) , true , bodyDesc , authToken , timeoutMs ) ;
130127}
131128
132129/**
@@ -139,10 +136,9 @@ export async function postMultipart<TRes>(
139136 apiPath : string ,
140137 formData : FormData ,
141138 authToken ?: string ,
142- userApiKey ?: string ,
143139 timeoutMs : number = 300000 ,
144140) : Promise < { data : TRes ; requestId : string | undefined } > {
145- return executePost < TRes > ( apiPath , formData , false , 'body=FormData' , authToken , userApiKey , timeoutMs ) ;
141+ return executePost < TRes > ( apiPath , formData , false , 'body=FormData' , authToken , timeoutMs ) ;
146142}
147143
148144/**
@@ -158,7 +154,6 @@ export async function callWithLocalFallback<TReq, TRes>(
158154 body : TReq ,
159155 localHandler : ( ) => Promise < TRes > ,
160156 authToken ?: string ,
161- userApiKey ?: string ,
162157 timeoutMs : number = 60000 ,
163158) : Promise < { data : TRes ; source : 'local' | 'remote' ; requestId ?: string } > {
164159 // 检查本地 Ollama 是否可用
@@ -179,7 +174,6 @@ export async function callWithLocalFallback<TReq, TRes>(
179174 apiPath ,
180175 body ,
181176 authToken ,
182- userApiKey ,
183177 timeoutMs ,
184178 ) ;
185179 return { data, source : 'remote' , requestId } ;
0 commit comments