diff --git a/STranslate/ViewModels/ServiceHandler.cs b/STranslate/ViewModels/ServiceHandler.cs index 0e5540aa..50b52076 100644 --- a/STranslate/ViewModels/ServiceHandler.cs +++ b/STranslate/ViewModels/ServiceHandler.cs @@ -116,9 +116,10 @@ public static async Task OpenAIHandlerAsync(ITranslator service, string content, UriBuilder uriBuilder = new(service.Url); - if (!uriBuilder.Path.EndsWith("/v1/completions")) + // 兼容旧版API: https://platform.openai.com/docs/guides/text-generation + if (!uriBuilder.Path.EndsWith("/v1/chat/completions") && !uriBuilder.Path.EndsWith("/v1/completions")) { - uriBuilder.Path = uriBuilder.Path.TrimEnd('/') + "/v1/completions"; + uriBuilder.Path = uriBuilder.Path.TrimEnd('/') + "/v1/chat/completions"; } var a_model = (service as TranslatorOpenAI)?.Model;