{"record":{"id":"9c9226457cc5d3aa","repo":"openai/openai-python","slug":"round-trip-is-only-supported-in-pydantic-v2","errorCode":null,"errorMessage":"round_trip is only supported in Pydantic v2","messagePattern":"round_trip is only supported in Pydantic v2","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/openai/_models.py","lineNumber":351,"sourceCode":"                exclude_defaults: Whether to exclude fields that are set to their default value.\n                exclude_none: Whether to exclude fields that have a value of `None`.\n                exclude_computed_fields: Whether to exclude computed fields.\n                    While this can be useful for round-tripping, it is usually recommended to use the dedicated\n                    `round_trip` parameter instead.\n                round_trip: If True, dumped values should be valid as input for non-idempotent types such as Json[T].\n                warnings: How to handle serialization errors. False/\"none\" ignores them, True/\"warn\" logs errors,\n                    \"error\" raises a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError].\n                fallback: A function to call when an unknown value is encountered. If not provided,\n                    a [`PydanticSerializationError`][pydantic_core.PydanticSerializationError] error is raised.\n                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            )","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/_models.py#L333-L369","documentation":"In the Pydantic v1 compatibility implementation of model_dump, the round_trip keyword exists for signature parity with Pydantic v2 but is not supported; only the default False is accepted, and any other value raises ValueError.","triggerScenarios":"Calling model.model_dump(round_trip=True) on an SDK model when the environment resolves to the Pydantic v1 compat layer.","commonSituations":"Copying Pydantic v2 example code (round_trip=True) into a project pinned to pydantic v1; upgrading the SDK but not pydantic.","solutions":["Remove round_trip=True (or set it to False) when running under Pydantic v1","Upgrade the environment to pydantic>=2 so the v2 implementation honoring round_trip is used"],"exampleFix":"# before\nd = obj.model_dump(round_trip=True)\n# after\nd = obj.model_dump()\n","handlingStrategy":"validation","validationCode":"import pydantic\nif pydantic.VERSION.startswith('1.'):\n    kwargs.pop('round_trip', None)  # not supported under v1\nobj.model_dump(**kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check pydantic.VERSION before forwarding v2-only kwargs","Upgrade to pydantic>=2 to use round_trip"],"tags":["pydantic","serialization","v1-compat","models"],"backgroundTag":"pydantic-version-mismatch","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}