Aflatoxins are a group of extremely toxic small molecules that have been involved in human hepatic and extrahepatic carcinogenesis as causative agents. Herein, we developed a real-time immuno polymerase chain reaction (IPCR) assay for the accurately quantitative detection of aflatoxins in agri-products base on a M13 phage containing aflatoxin anti-idiotypic nanobody and its encoding DNA which was used to design the specific primers. The limit of detection (LOD) of the assay is 0.02 ng/mL, which exhibits a 4-fold improvement over traditional phage ELISA. The developed method was successfully validated with the samples of corn, rice, peanut, and feedstuff, which are major aflatoxin-contaminated agri-products. And the recoveries were from 77.05 to 122.16%. For further validation, the developed assay was also compared with a reference HPLC method for the analysis of aflatoxins in corn and peanuts, and concordant results (R(2) = 0.991) were obtained. In this context, this study provides a novel opportunity to analyze aflatoxins in agri-products.