{"record":{"id":"7e2e3cf247b75ada","repo":"openai/openai-python","slug":"unable-to-automatically-parse-response-format-type-7e2e3c","errorCode":null,"errorMessage":"Unable to automatically parse response format type {text_format}","messagePattern":"Unable to automatically parse response format type (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/_parsing/_responses.py","lineNumber":157,"sourceCode":"            \"output\": output_list,\n        },\n    )\n\n\ndef parse_text(text: str, text_format: type[TextFormatT] | Omit) -> TextFormatT | None:\n    if not is_given(text_format):\n        return None\n\n    if is_basemodel_type(text_format):\n        return cast(TextFormatT, model_parse_json(text_format, text))\n\n    if is_dataclass_like_type(text_format):\n        if PYDANTIC_V1:\n            raise TypeError(f\"Non BaseModel types are only supported with Pydantic v2 - {text_format}\")\n\n        return pydantic.TypeAdapter(text_format).validate_json(text)\n\n    raise TypeError(f\"Unable to automatically parse response format type {text_format}\")\n\n\ndef get_input_tool_by_name(*, input_tools: Iterable[ToolParam], name: str) -> FunctionToolParam | None:\n    for tool in input_tools:\n        if tool[\"type\"] == \"function\" and tool.get(\"name\") == name:\n            return tool\n\n    return None\n\n\ndef parse_function_tool_arguments(\n    *,\n    input_tools: Iterable[ToolParam] | Omit | None,\n    function_call: ParsedResponseFunctionToolCall | ResponseFunctionToolCall,\n) -> object:\n    if input_tools is None or not is_given(input_tools):\n        return None\n","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/_parsing/_responses.py#L139-L175","documentation":"parse_text only supports pydantic BaseModel and dataclass-like types as text_format. Passing any other type (int, str, dict, arbitrary class) raises TypeError('Unable to automatically parse response format type ...').","triggerScenarios":"client.responses.parse(text_format=str) or text_format=some_plain_class.","commonSituations":"Expecting .parse() to return primitives; passing a schema dict instead of a Python type.","solutions":["Wrap the desired shape in a pydantic BaseModel (e.g. class Output(BaseModel): value: str)","Use responses.create with a raw text.format param and parse the output yourself"],"exampleFix":"# before\nclient.responses.parse(..., text_format=str)\n# after\nclass Output(BaseModel):\n    value: str\nresp = client.responses.parse(..., text_format=Output)\ntext = resp.output_text  # or resp.output_parsed.value","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def is_parseable_text_format(t: type) -> bool:\n    return is_basemodel_type(t) or is_dataclass_like_type(t)","tryCatchPattern":null,"preventionTips":["Wrap primitive outputs in a BaseModel","Never pass str/int/dict as text_format"],"tags":["responses","parsing","type-validation"],"backgroundTag":"unsupported-response-format","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}