In this study, we propose an imperfect economic production quantity model with both upstream and downstream trade credits. Trade credit is offered to the manufacturer by the supplier if the order quantity of raw material exceeds a predetermined value. Moreover, customers are permitted to pay the purchasing cost to the manufacturer after receiving the products. However, defective items are sometimes produced during the production process. Therefore, another assumption is made that defective items are produced during the production period and they all become perfect after a reworking process. In order to solve the model in several different cases, we show that all of the proposed costs functions are convex and optimal solutions are obtained mathematically for the production lot size and backlogged shortage. Furthermore, to discover the effects of a two-level trade credit period and the reworking of defective items, illustrative examples are provided as well as a sensitivity analysis to demonstrate the results of the model.