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

  1. 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)
  2. Or switch to a client that supports structured output (e.g. OpenAIChatCompletionClient against a structured-output-capable model)
  3. 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

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


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/e40a942010c9ca7d. Report an issue: GitHub.