microsoft/autogen · error · ValueError
Structured output is not currently supported for AzureAIChat
Error message
Structured output is not currently supported for AzureAIChatCompletionClient
What it means
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.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py:349
self,
messages: Sequence[LLMMessage],
tools: Sequence[Tool | ToolSchema],
json_output: Optional[bool | type[BaseModel]],
create_args: Dict[str, Any],
) -> None:
if self.model_info["vision"] is False:
for message in messages:
if isinstance(message, UserMessage):
if isinstance(message.content, list) and any(isinstance(x, Image) for x in message.content):
raise ValueError("Model does not support vision and image was provided")
if json_output is not None:
if self.model_info["json_output"] is False and json_output is True:
raise ValueError("Model does not support JSON output")
if isinstance(json_output, type):
# TODO: we should support this in the future.
raise ValueError("Structured output is not currently supported for AzureAIChatCompletionClient")
if json_output is True and "response_format" not in create_args:
create_args["response_format"] = "json_object"
if self.model_info["json_output"] is False and json_output is True:
raise ValueError("Model does not support JSON output")
if self.model_info["function_calling"] is False and len(tools) > 0:
raise ValueError("Model does not support function calling")
async def create(
self,
messages: Sequence[LLMMessage],
*,
tools: Sequence[Tool | ToolSchema] = [],
tool_choice: Tool | Literal["auto", "required", "none"] = "auto",
json_output: Optional[bool | type[BaseModel]] = None,
extra_create_args: Mapping[str, Any] = {},
cancellation_token: Optional[CancellationToken] = None,View on GitHub (pinned to 027ecf0a37)
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
Example fix
# before
result = await client.create(msgs, json_output=MyResponseModel)
# after
msgs = msgs + [SystemMessage("Reply ONLY with JSON matching: " + json.dumps(MyResponseModel.model_json_schema()))]
result = await client.create(msgs, json_output=True)
parsed = MyResponseModel.model_validate_json(result.content) Defensive patterns
Strategy: type-guard
Validate before calling
if isinstance(json_output, type):
# structured output unsupported: downgrade to JSON mode + prompt schema
json_output = True
prompt_schema = cls.model_json_schema() Type guard
def is_structured_output_request(json_output) -> bool:
return isinstance(json_output, type) Try / catch
try:
result = await client.create(msgs, json_output=MyModel)
except ValueError as e:
if "Structured output is not currently supported" in str(e):
result = await create_with_prompt_schema(client, msgs, MyModel)
else:
raise Prevention
- 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
When it happens
Trigger: Calling create(..., json_output=MyResponseModel) where MyResponseModel is a class, mirroring usage supported by other AutoGen clients.
Common situations: 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.
Related errors
- structured output is not currently supported in SKChatComple
- Invalid configuration: {str(e)}
- endpoint must be a valid URL starting with http:// or https:
- top must be a positive integer
- semantic_config_name must be provided when query_type is 'se
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/e40a942010c9ca7d.
Report an issue: GitHub.