Abstract. This paper develops the Jungle model in a credit portfolio framework. The Jungle model is able to model credit contagion, produce doubly-peaked probability distributions for the total default loss and endogenously generate quasi phase transitions, potentially leading to systemic credit events which happen unexpectedly and without an underlying single cause. We show the Jungle model provides the optimal probability distribution for credit losses, under some reasonable empirical constraints. The Dandelion model, a particular case of the Jungle model, is presented, motivated and exactly solved. The Dandelion model provides an explicit example of doubly-peaked probability distribution for the credit losses. The Diamond model, another instance of the Jungle model, experiences the so called quasi phase transitions; in particular, both the U.S. subprime and the European sovereign crises are shown to be potential examples of quasi phase transitions. We suggest how the Jungle model is able to explain a series of empirical stylized facts in credit portfolios, hard to reconcile by some standard credit portfolio models. We look at model risk in a credit risk framework under the Jungle model, especially in relation to systemic risks posed by doubly-peaked distributions and quasi phase transitions.