fix(gateway): strip service_tier and usage details from OpenAI responses
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
00056c5405
commit
a4fa4f47d6
|
|
@ -52,8 +52,9 @@ export function sanitizeOpenAIResponse(json: any, aliasModel: string): any {
|
||||||
json.id = generateOpaqueId('cmpl');
|
json.id = generateOpaqueId('cmpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove system_fingerprint (OpenAI-specific)
|
// Remove OpenAI-specific fields
|
||||||
delete json.system_fingerprint;
|
delete json.system_fingerprint;
|
||||||
|
delete json.service_tier;
|
||||||
|
|
||||||
// Sanitize choices — remove OpenAI-specific logprobs if present
|
// Sanitize choices — remove OpenAI-specific logprobs if present
|
||||||
if (json.choices) {
|
if (json.choices) {
|
||||||
|
|
@ -62,6 +63,12 @@ export function sanitizeOpenAIResponse(json: any, aliasModel: string): any {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanitize usage — remove OpenAI-specific detail breakdowns
|
||||||
|
if (json.usage) {
|
||||||
|
const { prompt_tokens, completion_tokens, total_tokens } = json.usage;
|
||||||
|
json.usage = { prompt_tokens, completion_tokens, total_tokens };
|
||||||
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,9 +128,10 @@ export function buildOpenAIStreamTransform(effectiveModel: string, aliasModel: s
|
||||||
return `"id":"${generateOpaqueId('cmpl')}"`;
|
return `"id":"${generateOpaqueId('cmpl')}"`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Strip system_fingerprint
|
// Strip system_fingerprint and service_tier
|
||||||
result = result.replace(/,?\s*"system_fingerprint"\s*:\s*"[^"]*"/g, '');
|
result = result.replace(/,?\s*"system_fingerprint"\s*:\s*"[^"]*"/g, '');
|
||||||
result = result.replace(/,?\s*"system_fingerprint"\s*:\s*null/g, '');
|
result = result.replace(/,?\s*"system_fingerprint"\s*:\s*null/g, '');
|
||||||
|
result = result.replace(/,?\s*"service_tier"\s*:\s*"[^"]*"/g, '');
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue