[new model] move code to the model and model.api plugins