Skip to content

Commit b2e8576

Browse files
committed
Added backup host key
1 parent 76bcc86 commit b2e8576

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pages/api/models.api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ const handler = async (req: Request): Promise<Response> => {
117117
const headers = {
118118
"Content-Type": "application/json",
119119
...(OPENAI_API_TYPE === "openai" && {
120-
Authorization: `Bearer ${currentApiKey ?? apiKey}`
120+
Authorization: `Bearer ${currentApiKey.length > 0 ? currentApiKey : apiKey}`
121121
}),
122122
...(OPENAI_API_TYPE === "openai" &&
123123
OPENAI_ORGANIZATION && {
124124
"OpenAI-Organization": OPENAI_ORGANIZATION
125125
}),
126126
...(OPENAI_API_TYPE === "azure" && {
127-
"api-key": currentApiKey ?? apiKey
127+
"api-key": currentApiKey.length > 0 ? currentApiKey : apiKey
128128
})
129129
}
130130

utils/server/openAiClient.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,18 @@ function createOpenAiConfiguration(apiKey: string, modelId: string, dangerouslyA
114114
OPENAI_AZURE_DEPLOYMENT_ID,
115115
modelId
116116
)}`,
117-
apiKey: currentApiKey ?? apiKey,
117+
apiKey: currentApiKey.length > 0 ? currentApiKey : apiKey,
118118
defaultQuery: {
119119
"api-version": process.env.OPENAI_API_VERSION
120120
},
121121
defaultHeaders: {
122-
"api-key": currentApiKey ?? apiKey
122+
"api-key": currentApiKey.length > 0 ? currentApiKey : apiKey
123123
}
124124
}
125125
} else {
126126
configuration = {
127127
baseURL: `${currentHost}/v1`,
128-
apiKey: currentApiKey ?? apiKey,
128+
apiKey: currentApiKey.length > 0 ? currentApiKey : apiKey,
129129
organization: OPENAI_ORGANIZATION
130130
}
131131
}

0 commit comments

Comments
 (0)