{"record":{"id":"b01f80d504669aaf","repo":"openai/openai-python","slug":"non-basemodel-types-are-only-supported-with-pydant-b01f80","errorCode":null,"errorMessage":"Non BaseModel types are only supported with Pydantic v2 - {text_format}","messagePattern":"Non BaseModel types are only supported with Pydantic v2 - (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/openai/lib/_parsing/_responses.py","lineNumber":153,"sourceCode":"    return construct_type_unchecked(\n        type_=ParsedResponse[TextFormatT],\n        value={\n            **response.to_dict(),\n            \"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,","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/lib/_parsing/_responses.py#L135-L171","documentation":"parse_text (used by responses.parse) JSON-parses the model output into text_format. Dataclass-like types are handled with pydantic.TypeAdapter, which requires Pydantic v2; under Pydantic v1 a dataclass/TypedDict text_format raises this TypeError.","triggerScenarios":"Using client.responses.parse(text_format=MyDataclass) with pydantic v1 installed.","commonSituations":"Environments pinned to pydantic 1.x by another dependency (e.g. older LangChain, FastAPI 0.x).","solutions":["Upgrade to pydantic>=2","Use a pydantic.BaseModel subclass instead of a dataclass/TypedDict"],"exampleFix":"# before\n@dataclass\nclass Output: ...\nclient.responses.parse(..., text_format=Output)\n# after\nclass Output(pydantic.BaseModel): ...\nclient.responses.parse(..., text_format=Output)","handlingStrategy":"validation","validationCode":"import pydantic; assert int(pydantic.VERSION.split(\".\")[0]) >= 2 or is_basemodel_type(text_format), \"pydantic v2 required for dataclass text_format\"","typeGuard":"def responses_parse_safe(t: type) -> bool:\n    return is_basemodel_type(t) or (not PYDANTIC_V1 and is_dataclass_like_type(t))","tryCatchPattern":"try:\n    parsed = parse_response(response, text_format=Output)\nexcept TypeError as e:\n    raise RuntimeError(f\"unsupported text_format: {e}\") from e","preventionTips":["Use BaseModel output types","Keep pydantic>=2 in environments using structured outputs"],"tags":["responses","parsing","pydantic","version-conflict"],"backgroundTag":"dependency-version-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}