{"id":10012,"library":"openresponses-types","title":"OpenResponses Types","description":"The `openresponses-types` library provides a Python SDK for the OpenResponses specification, offering standardized data types and models for structured interactions, particularly for AI agents. It leverages Pydantic for robust data validation, serialization, and deserialization of response and prompt structures. The current version is 2.3.0.post1, with releases aligning with updates to the underlying OpenResponses specification.","status":"active","version":"2.3.0.post1","language":"en","source_language":"en","source_url":"https://github.com/mozilla-ai/openresponses-python","tags":["AI","LLM","data-types","specification","pydantic","serialization","validation"],"install":[{"cmd":"pip install openresponses-types","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"`openresponses-types` is a meta-package that depends on `openresponses-python` for the actual implementation.","package":"openresponses-python","optional":false},{"reason":"Core dependency for data modeling, validation, and serialization. Requires Pydantic V2.","package":"pydantic>=2.0.0","optional":false}],"imports":[{"note":"The PyPI package `openresponses-types` installs the Python package `openresponses`. Types are found under `openresponses.types`.","wrong":"from openresponses_types import OpenResponse","symbol":"OpenResponse","correct":"from openresponses.types import OpenResponse"},{"symbol":"AgentResponse","correct":"from openresponses.types import AgentResponse"},{"symbol":"HumanResponse","correct":"from openresponses.types import HumanResponse"},{"note":"Specific model components are often nested in `openresponses.types.model`.","wrong":"from openresponses.types import ChatMLMessage","symbol":"ChatMLMessage","correct":"from openresponses.types.model import ChatMLMessage"},{"symbol":"Action","correct":"from openresponses.types.action import Action"}],"quickstart":{"code":"from openresponses.types import AgentResponse, OpenResponse\nfrom openresponses.types.model import ChatMLMessage\n\n# Create an AgentResponse\nagent_msg = ChatMLMessage(role=\"assistant\", content=\"Hello, how can I help you?\")\nagent_response = AgentResponse(\n    model_name=\"gpt-4\",\n    messages=[agent_msg]\n)\n\n# Create an OpenResponse containing the agent's response\nopen_response = OpenResponse(\n    response=agent_response,\n    prompt_hash=\"example_hash_123\"\n)\n\n# Print the OpenResponse object (serialized to JSON)\nprint(\"OpenResponse object created:\")\nprint(open_response.model_dump_json(indent=2))\n\n# Example of deserialization from JSON string\njson_data = open_response.model_dump_json()\nreconstructed_response = OpenResponse.model_validate_json(json_data)\nprint(\"\\nOpenResponse object deserialized:\")\nprint(reconstructed_response.model_dump_json(indent=2))\n","lang":"python","description":"This quickstart demonstrates how to create an `AgentResponse` containing a `ChatMLMessage`, embed it within an `OpenResponse`, and then serialize and deserialize the entire structure using Pydantic's V2 methods."},"warnings":[{"fix":"Ensure your imports start with `from openresponses.types` or `from openresponses.types.model` etc., not `openresponses_types`.","message":"The PyPI package name (`openresponses-types`) is different from the top-level Python package name you import (`openresponses`). Always use `from openresponses.types import ...`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade Pydantic to version 2 or greater (`pip install 'pydantic>=2.0.0'`) and update your Pydantic model usage (e.g., `model_dump_json()` instead of `json()`, `model_validate()` instead of direct class instantiation from dict).","message":"This library explicitly requires Pydantic V2. Projects using Pydantic V1 will encounter conflicts and `pydantic.ValidationError` or `AttributeError` if Pydantic V1 methods are used.","severity":"breaking","affected_versions":"All versions (>=1.0.0)"},{"fix":"Consult the OpenResponses specification and ensure all fields, types, and constraints (e.g., enum values, regex patterns) are strictly followed when constructing objects or deserializing data.","message":"The `OpenResponse` specification is strict. Any data provided that does not conform to the defined schemas will result in `pydantic.ValidationError`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Change your import statements from `from openresponses_types import ...` to `from openresponses.types import ...`.","cause":"Attempting to import directly from the PyPI package name (openresponses-types) instead of the actual installed Python package (openresponses).","error":"ModuleNotFoundError: No module named 'openresponses_types'"},{"fix":"Replace `.json()` with `.model_dump_json()` and `.dict()` with `.model_dump()` to align with Pydantic V2 API changes.","cause":"This error typically occurs when using Pydantic V1 methods (`.json()`, `.dict()`) on Pydantic V2 models. `openresponses-types` uses Pydantic V2.","error":"AttributeError: 'AgentResponse' object has no attribute 'json'"},{"fix":"Carefully review the traceback to identify the specific field causing the error. Check the OpenResponses specification or the model definitions (`.model_json_schema()`) to ensure your data matches the expected structure and types.","cause":"The data provided to construct or validate an OpenResponse model does not conform to the schema (e.g., missing required fields, incorrect types, invalid enum values).","error":"pydantic.ValidationError: X validation error for Y"}]}