fix: append routeID to model proxy URL and drop X-GPUStack-Model header

This commit is contained in:
jialin
2026-05-06 12:27:22 +08:00
committed by jialin
parent 9914db6b96
commit 2592f44bc2
14 changed files with 92 additions and 67 deletions
+6 -4
View File
@@ -5,17 +5,18 @@ import { fomatNodeJsParams, formatCurlArgs, formatPyParams } from './utils';
export const generateSpeechToTextCurlCode = ({
api: url,
modelProxy,
routeID,
parameters
}: Record<string, any>) => {
const host = window.location.origin;
// replace url OPENAI_COMPATIBLE with GPUSTACK
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
const api = modelProxy ? `${MODEL_PROXY}/${routeID}/\${YOUR_API_PATH}` : url;
// ========================= Curl =========================
const curlCode = `
curl ${host}${api} \\
-H "Content-Type: multipart/form-data" \\
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\${modelProxy ? `\n-H "X-GPUStack-Model: ${parameters.model}" \\` : ''}
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\
-F model="${parameters.model}" \\
-F file="@/path/to/file/audio.mp3;type=audio/mpeg" \\
${formatCurlArgs(_.omit(parameters, 'model'), true)}`
@@ -85,16 +86,17 @@ main();`.trim();
export const generateTextToSpeechCurlCode = ({
api: url,
modelProxy,
routeID,
parameters
}: Record<string, any>) => {
const host = window.location.origin;
const api = modelProxy ? `${MODEL_PROXY}/\${YOUR_API_PATH}` : url;
const api = modelProxy ? `${MODEL_PROXY}/${routeID}/\${YOUR_API_PATH}` : url;
// ========================= Curl =========================
const curlCode = `
curl ${host}${api} \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\${modelProxy ? `\n-H "X-GPUStack-Model: ${parameters.model}" \\` : ''}
-H "Authorization: Bearer $\{YOUR_GPUSTACK_API_KEY}" \\
${formatCurlArgs(parameters, false)} \\\n--output output.${parameters.response_format}`.trim();
return curlCode;