{"record":{"id":"219b911f9162978a","repo":"microsoft/semantic-kernel","slug":"the-settings-must-be-an-openaichatpromptexecutions","errorCode":null,"errorMessage":"The settings must be an OpenAIChatPromptExecutionSettings.","messagePattern":"The settings must be an OpenAIChatPromptExecutionSettings\\.","errorType":"exception","errorClass":"ServiceInvalidExecutionSettingsError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py","lineNumber":143,"sourceCode":"                        content=\"\",\n                        choice_index=i,\n                        inner_content=chunk,\n                        ai_model_id=settings.ai_model_id,\n                        metadata=chunk_metadata,\n                        function_invoke_attempt=function_invoke_attempt,\n                    )\n                    for i in range(settings.number_of_responses or 1)\n                ]\n            else:\n                yield [\n                    self._create_streaming_chat_message_content(chunk, choice, chunk_metadata, function_invoke_attempt)\n                    for choice in chunk.choices\n                ]\n\n    @override\n    def _verify_function_choice_settings(self, settings: \"PromptExecutionSettings\") -> None:\n        if not isinstance(settings, OpenAIChatPromptExecutionSettings):\n            raise ServiceInvalidExecutionSettingsError(\"The settings must be an OpenAIChatPromptExecutionSettings.\")\n        if settings.number_of_responses is not None and settings.number_of_responses > 1:\n            raise ServiceInvalidExecutionSettingsError(\n                \"Auto-invocation of tool calls may only be used with a \"\n                \"OpenAIChatPromptExecutions.number_of_responses of 1.\"\n            )\n\n    @override\n    def _update_function_choice_settings_callback(\n        self,\n    ) -> Callable[[\"FunctionCallChoiceConfiguration\", \"PromptExecutionSettings\", FunctionChoiceType], None]:\n        return update_settings_from_function_call_configuration\n\n    @override\n    def _reset_function_choice_settings(self, settings: \"PromptExecutionSettings\") -> None:\n        if hasattr(settings, \"tool_choice\"):\n            settings.tool_choice = None\n        if hasattr(settings, \"tools\"):\n            settings.tools = None","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/open_ai_chat_completion_base.py#L125-L161","documentation":"Raised in _verify_function_choice_settings when the settings object passed to the tool-call auto-invocation path is not an instance of OpenAIChatPromptExecutionSettings. This method is overridden from the base AI service to enforce that only OpenAI-specific execution settings carry the function-call configuration needed for tool invocation.","triggerScenarios":"Calling a chat completion with auto-function-invocation enabled but passing a generic PromptExecutionSettings or a non-OpenAI settings subclass (e.g., a custom settings class) instead of OpenAIChatPromptExecutionSettings.","commonSituations":"Building a multi-provider abstraction that passes a base PromptExecutionSettings to all services; accidentally using settings from a different connector (e.g., Azure-specific or a third-party connector) with the OpenAI chat completion service; misconfigured kernel service-resolver that returns the wrong settings type.","solutions":["Pass OpenAIChatPromptExecutionSettings to the completion call, not the base PromptExecutionSettings","Use kernel.get_prompt_execution_settings_from_settings(settings) to auto-convert, or construct OpenAIChatPromptExecutionSettings directly","Ensure your kernel's service_id mapping resolves to the OpenAI chat service when expecting OpenAI settings"],"exampleFix":"# before\nfrom semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings\nsettings = PromptExecutionSettings()\n# after\nfrom semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings\nsettings = OpenAIChatPromptExecutionSettings()","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings\n\nif not isinstance(settings, OpenAIChatPromptExecutionSettings):\n    settings = OpenAIChatPromptExecutionSettings(**settings.model_dump() if hasattr(settings, 'model_dump') else {})","typeGuard":"from semantic_kernel.connectors.ai.open_ai import OpenAIChatPromptExecutionSettings\n\ndef is_openai_chat_settings(settings) -> bool:\n    return isinstance(settings, OpenAIChatPromptExecutionSettings)","tryCatchPattern":null,"preventionTips":["Always construct provider-specific settings objects rather than passing the base class","If your code handles multiple providers, branch on provider type before calling the completion method"],"tags":["openai","type-validation","function-calling","execution-settings"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}