{"record":{"id":"59d64841985756b1","repo":"openai/openai-python","slug":"exclude-computed-fields-is-only-supported-in-pydan","errorCode":null,"errorMessage":"exclude_computed_fields is only supported in Pydantic v2","messagePattern":"exclude_computed_fields is only supported in Pydantic v2","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/_models.py","lineNumber":361,"sourceCode":"                serialize_as_any: Whether to serialize fields with duck-typing serialization behavior.\n\n            Returns:\n                A dictionary representation of the model.\n            \"\"\"\n            if mode not in {\"json\", \"python\"}:\n                raise ValueError(\"mode must be either 'json' or 'python'\")\n            if round_trip != False:\n                raise ValueError(\"round_trip is only supported in Pydantic v2\")\n            if warnings != True:\n                raise ValueError(\"warnings is only supported in Pydantic v2\")\n            if context is not None:\n                raise ValueError(\"context is only supported in Pydantic v2\")\n            if serialize_as_any != False:\n                raise ValueError(\"serialize_as_any is only supported in Pydantic v2\")\n            if fallback is not None:\n                raise ValueError(\"fallback is only supported in Pydantic v2\")\n            if exclude_computed_fields != False:\n                raise ValueError(\"exclude_computed_fields is only supported in Pydantic v2\")\n            dumped = super().dict(  # pyright: ignore[reportDeprecated]\n                include=include,\n                exclude=exclude,\n                by_alias=by_alias if by_alias is not None else False,\n                exclude_unset=exclude_unset,\n                exclude_defaults=exclude_defaults,\n                exclude_none=exclude_none,\n            )\n\n            return cast(\"dict[str, Any]\", json_safe(dumped)) if mode == \"json\" else dumped\n\n        @override\n        def model_dump_json(\n            self,\n            *,\n            indent: int | None = None,\n            ensure_ascii: bool = False,\n            include: IncEx | None = None,","sourceCodeStart":343,"sourceCodeEnd":379,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_models.py#L343-L379","documentation":"exclude_computed_fields (a Pydantic v2 model_dump option to omit computed fields) is not available in the Pydantic v1 compat shim; passing anything other than False raises ValueError.","triggerScenarios":"Calling model.model_dump(exclude_computed_fields=True) on SDK models when the Pydantic v1 implementation is active.","commonSituations":"Trying to strip computed/derived fields before logging or storing payloads, using Pydantic v2-style calls in a v1 environment.","solutions":["Upgrade to pydantic>=2","Under v1, exclude the fields manually: {k: v for k, v in obj.model_dump().items() if k not in computed_names}"],"exampleFix":"# before\nd = obj.model_dump(exclude_computed_fields=True)\n# after\nd = {k: v for k, v in obj.model_dump().items() if k not in {'computed_field'}}\n","handlingStrategy":"validation","validationCode":"import pydantic\nif pydantic.VERSION.startswith('1.'):\n    kwargs.pop('exclude_computed_fields', None)\nobj.model_dump(**kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip computed fields via dict comprehension under v1"],"tags":["pydantic","serialization","v1-compat","computed-fields"],"backgroundTag":"pydantic-version-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}