microsoft/autogen · error · ValueError

Model does not support JSON output

Error message

Model does not support JSON output

What it means

First of two identical guards in AzureAIChatCompletionClient._validate_model_info, inside the 'if json_output is not None' block: raised when self.model_info['json_output'] is False and the caller passes json_output=True. The model was declared as not supporting JSON mode, so the client blocks the request before setting response_format='json_object'.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/models/azure/_azure_ai_client.py:345

            self._total_usage.completion_tokens + usage.completion_tokens,
        )

    def _validate_model_info(
        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] = [],

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Set json_output=True in model_info if the deployed model supports JSON mode
  2. Otherwise drop json_output=True and parse/repair the response yourself (e.g. json.loads with retry)
  3. Use a model/deployment that supports JSON mode for structured workflows

Example fix

# before
model_info = ModelInfo(family="gpt-4o", vision=True, function_calling=True,
                      json_output=False, structured_output=False)
await client.create(msgs, json_output=True)

# after
model_info = ModelInfo(family="gpt-4o", vision=True, function_calling=True,
                      json_output=True, structured_output=False)
await client.create(msgs, json_output=True)
Defensive patterns

Strategy: validation

Validate before calling

if json_output is True and client.model_info["json_output"] is False:
    json_output = None  # or raise a clear config error before the request

Prevention

When it happens

Trigger: Calling create(..., json_output=True) on a client whose model_info has json_output=False; enabling a generic 'always use JSON output' wrapper around all model calls.

Common situations: ModelInfo copied from a template with json_output=False while the deployed model (e.g. GPT-4o) does support JSON mode; older model families (e.g. early Llama on Foundry) that genuinely lack JSON mode.

Related errors


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