{"record":{"id":"650654661d4286c5","repo":"microsoft/semantic-kernel","slug":"chat-completions-not-found","errorCode":null,"errorMessage":"Chat completions not found","messagePattern":"Chat completions not found","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.MistralAI/Client/MistralClient.cs","lineNumber":73,"sourceCode":"        var endpoint = this.GetEndpoint(mistralExecutionSettings, path: \"chat/completions\");\n        var autoInvoke = kernel is not null && mistralExecutionSettings.ToolCallBehavior?.MaximumAutoInvokeAttempts > 0 && s_inflightAutoInvokes.Value < MaxInflightAutoInvokes;\n\n        for (int requestIndex = 1; ; requestIndex++)\n        {\n            var chatRequest = this.CreateChatCompletionRequest(modelId, stream: false, chatHistory, mistralExecutionSettings, kernel);\n\n            ChatCompletionResponse? responseData = null;\n            List<ChatMessageContent> responseContent;\n            using (var activity = ModelDiagnostics.StartCompletionActivity(this._endpoint, this._modelId, ModelProvider, chatHistory, mistralExecutionSettings))\n            {\n                try\n                {\n                    using var httpRequestMessage = this.CreatePost(chatRequest, endpoint, this._apiKey, stream: false);\n                    responseData = await this.SendRequestAsync<ChatCompletionResponse>(httpRequestMessage, cancellationToken).ConfigureAwait(false);\n                    this.LogUsage(responseData?.Usage);\n                    if (responseData is null || responseData.Choices is null || responseData.Choices.Count == 0)\n                    {\n                        throw new KernelException(\"Chat completions not found\");\n                    }\n                }\n                catch (Exception ex) when (activity is not null)\n                {\n                    activity.SetError(ex);\n\n                    // Capture available metadata even if the operation failed.\n                    if (responseData is not null)\n                    {\n                        if (responseData.Id is string id)\n                        {\n                            activity.SetResponseId(id);\n                        }\n\n                        if (responseData.Usage is MistralUsage usage)\n                        {\n                            if (usage.PromptTokens is int promptTokens)\n                            {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.MistralAI/Client/MistralClient.cs#L55-L91","documentation":"Thrown by MistralClient.GetChatMessageContentsAsync when the non-streaming chat completion response is null, has a null Choices collection, or has zero choices. The connector cannot produce ChatMessageContent without at least one choice. It is a KernelException raised after the HTTP call succeeded but the payload was empty.","triggerScenarios":"The Mistral API returned a 2xx response with no choices (e.g. content filtered entirely, all candidates blocked, an empty completion, or an unexpected API-side issue).","commonSituations":"Safety/content filters rejecting the entire generation; misconfigured model id; API quota/availability returning a degenerate 200; transient API faults; prompt that triggers a moderation block.","solutions":["Inspect the raw response and any moderation/safety fields (enable logging) to see why no choice was returned.","Retry once for transient API faults.","Adjust the prompt or moderation settings if content was filtered.","Verify the model id is valid and your plan has access to it."],"exampleFix":"// before\nvar result = await kernel.InvokePromptAsync(prompt, new(new MistralAIPromptExecutionSettings()));  // throws\n\n// after (handle empty-completion gracefully)\ntry\n{\n    var result = await kernel.InvokePromptAsync(prompt, new(new MistralAIPromptExecutionSettings()));\n}\ncatch (KernelException ex) when (ex.Message == \"Chat completions not found\")\n{\n    logger.LogWarning(\"Mistral returned no chat completions; prompt may be filtered.\");\n    // fallback or re-prompt\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var result = await kernel.InvokePromptAsync(prompt, new(new MistralAIPromptExecutionSettings()));\n}\ncatch (KernelException ex) when (ex.Message == \"Chat completions not found\")\n{\n    logger.LogWarning(\"Mistral returned no chat completions; prompt may be filtered or model unavailable.\");\n    // fallback, re-prompt, or surface to user\n}","preventionTips":["Enable response logging to inspect safety/moderation fields.","Retry once for transient API faults.","Adjust prompts that may trip content filters.","Confirm the model id and your plan's access."],"tags":["mistral","chat","response","empty-result","content-filter"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}