{"record":{"id":"e40a942010c9ca7d","repo":"microsoft/autogen","slug":"structured-output-is-not-currently-supported-for-a","errorCode":null,"errorMessage":"Structured output is not currently supported for AzureAIChatCompletionClient","messagePattern":"Structured output is not currently supported for AzureAIChatCompletionClient","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py","lineNumber":349,"sourceCode":"        self,\n        messages: Sequence[LLMMessage],\n        tools: Sequence[Tool | ToolSchema],\n        json_output: Optional[bool | type[BaseModel]],\n        create_args: Dict[str, Any],\n    ) -> None:\n        if self.model_info[\"vision\"] is False:\n            for message in messages:\n                if isinstance(message, UserMessage):\n                    if isinstance(message.content, list) and any(isinstance(x, Image) for x in message.content):\n                        raise ValueError(\"Model does not support vision and image was provided\")\n\n        if json_output is not None:\n            if self.model_info[\"json_output\"] is False and json_output is True:\n                raise ValueError(\"Model does not support JSON output\")\n\n            if isinstance(json_output, type):\n                # TODO: we should support this in the future.\n                raise ValueError(\"Structured output is not currently supported for AzureAIChatCompletionClient\")\n\n            if json_output is True and \"response_format\" not in create_args:\n                create_args[\"response_format\"] = \"json_object\"\n\n        if self.model_info[\"json_output\"] is False and json_output is True:\n            raise ValueError(\"Model does not support JSON output\")\n        if self.model_info[\"function_calling\"] is False and len(tools) > 0:\n            raise ValueError(\"Model does not support function calling\")\n\n    async def create(\n        self,\n        messages: Sequence[LLMMessage],\n        *,\n        tools: Sequence[Tool | ToolSchema] = [],\n        tool_choice: Tool | Literal[\"auto\", \"required\", \"none\"] = \"auto\",\n        json_output: Optional[bool | type[BaseModel]] = None,\n        extra_create_args: Mapping[str, Any] = {},\n        cancellation_token: Optional[CancellationToken] = None,","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py#L331-L367","documentation":"Raised by AzureAIChatCompletionClient._validate_model_info when json_output is passed as a type (isinstance(json_output, type), i.e. a Pydantic BaseModel subclass) instead of a bool. Structured output (schema-enforced responses) is explicitly a TODO ('we should support this in the future') for this client, so it fails fast rather than silently ignoring the schema.","triggerScenarios":"Calling create(..., json_output=MyResponseModel) where MyResponseModel is a class, mirroring usage supported by other AutoGen clients.","commonSituations":"Porting code from OpenAIChatCompletionClient or other clients where passing a Pydantic model to json_output produces schema-constrained output; following older/tutorials docs that assume uniform structured-output support.","solutions":["Pass json_output=True instead and instruct the model to emit JSON matching your schema via the prompt, then validate with MyResponseModel.model_validate_json(text)","Or switch to a client that supports structured output (e.g. OpenAIChatCompletionClient against a structured-output-capable model)","Watch autogen-ext releases — the TODO indicates native support may be added"],"exampleFix":"# before\nresult = await client.create(msgs, json_output=MyResponseModel)\n\n# after\nmsgs = msgs + [SystemMessage(\"Reply ONLY with JSON matching: \" + json.dumps(MyResponseModel.model_json_schema()))]\nresult = await client.create(msgs, json_output=True)\nparsed = MyResponseModel.model_validate_json(result.content)","handlingStrategy":"type-guard","validationCode":"if isinstance(json_output, type):\n    # structured output unsupported: downgrade to JSON mode + prompt schema\n    json_output = True\n    prompt_schema = cls.model_json_schema()","typeGuard":"def is_structured_output_request(json_output) -> bool:\n    return isinstance(json_output, type)","tryCatchPattern":"try:\n    result = await client.create(msgs, json_output=MyModel)\nexcept ValueError as e:\n    if \"Structured output is not currently supported\" in str(e):\n        result = await create_with_prompt_schema(client, msgs, MyModel)\n    else:\n        raise","preventionTips":["Do not pass Pydantic classes as json_output to this client","Wrap structured-output needs in a helper that injects the schema into the prompt and validates the response","Track upstream support for structured output in this client"],"tags":["azure","structured-output","pydantic","not-supported"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}