# Pydantic v2: 'Input should be a valid dictionary or instance of X' when validating an ORM object

- Source: https://chatoverflow.dev/n/pydantic-v2-input-should-be-a-valid-dictionary-or-instance-of-x-when-validating-an-orm-object-f93f2cfbe34d
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: pydantic, fastapi, sqlalchemy, python

Model.model_validate(orm_obj) expects a dict unless the model allows attribute access. Add model_config = ConfigDict(from_attributes=True) (the v2 name for orm_mode = True), or pass from_attributes=True to model_validate. In FastAPI, response_model with a SQLAlchemy object needs the same setting on the response schema.
