MCPcopy
hub / github.com/ChatGPTNextWeb/NextChat / getHeaders

Function getHeaders

app/client/api.ts:244–366  ·  view source on GitHub ↗
(ignoreHeaders: boolean = false)

Source from the content-addressed store, hash-verified

242}
243
244export function getHeaders(ignoreHeaders: boolean = false) {
245 const accessStore = useAccessStore.getState();
246 const chatStore = useChatStore.getState();
247 let headers: Record<string, string> = {};
248 if (!ignoreHeaders) {
249 headers = {
250 "Content-Type": "application/json",
251 Accept: "application/json",
252 };
253 }
254
255 const clientConfig = getClientConfig();
256
257 function getConfig() {
258 const modelConfig = chatStore.currentSession().mask.modelConfig;
259 const isGoogle = modelConfig.providerName === ServiceProvider.Google;
260 const isAzure = modelConfig.providerName === ServiceProvider.Azure;
261 const isAnthropic = modelConfig.providerName === ServiceProvider.Anthropic;
262 const isBaidu = modelConfig.providerName == ServiceProvider.Baidu;
263 const isByteDance = modelConfig.providerName === ServiceProvider.ByteDance;
264 const isAlibaba = modelConfig.providerName === ServiceProvider.Alibaba;
265 const isMoonshot = modelConfig.providerName === ServiceProvider.Moonshot;
266 const isIflytek = modelConfig.providerName === ServiceProvider.Iflytek;
267 const isDeepSeek = modelConfig.providerName === ServiceProvider.DeepSeek;
268 const isXAI = modelConfig.providerName === ServiceProvider.XAI;
269 const isChatGLM = modelConfig.providerName === ServiceProvider.ChatGLM;
270 const isSiliconFlow =
271 modelConfig.providerName === ServiceProvider.SiliconFlow;
272 const isAI302 = modelConfig.providerName === ServiceProvider["302.AI"];
273 const isEnabledAccessControl = accessStore.enabledAccessControl();
274 const apiKey = isGoogle
275 ? accessStore.googleApiKey
276 : isAzure
277 ? accessStore.azureApiKey
278 : isAnthropic
279 ? accessStore.anthropicApiKey
280 : isByteDance
281 ? accessStore.bytedanceApiKey
282 : isAlibaba
283 ? accessStore.alibabaApiKey
284 : isMoonshot
285 ? accessStore.moonshotApiKey
286 : isXAI
287 ? accessStore.xaiApiKey
288 : isDeepSeek
289 ? accessStore.deepseekApiKey
290 : isChatGLM
291 ? accessStore.chatglmApiKey
292 : isSiliconFlow
293 ? accessStore.siliconflowApiKey
294 : isIflytek
295 ? accessStore.iflytekApiKey && accessStore.iflytekApiSecret
296 ? accessStore.iflytekApiKey + ":" + accessStore.iflytekApiSecret
297 : ""
298 : isAI302
299 ? accessStore.ai302ApiKey
300 : accessStore.openaiApiKey;
301 return {

Callers 15

chatMethod · 0.90
speechMethod · 0.90
chatMethod · 0.90
usageMethod · 0.90
modelsMethod · 0.90
chatMethod · 0.90
modelsMethod · 0.90
chatMethod · 0.90
chatMethod · 0.90
chatMethod · 0.90
modelsMethod · 0.90
chatMethod · 0.90

Calls 5

getClientConfigFunction · 0.90
getConfigFunction · 0.85
getAuthHeaderFunction · 0.85
getBearerTokenFunction · 0.85
validStringFunction · 0.85

Tested by

no test coverage detected