Optical imaging of targeted compartments within living animals has been widely adopted in many research areas. In particular, various fluorescence-based probes and emerged photoacoustic molecules that enable sensitive and specific imaging through tissue have greatly advanced clinically relevant studies. However, delivery and signal penetration have placed requirements on the performance of conventional optical probes. Here, we use hallow tantalum oxide (TaOx) nanoparticles to enclose fluorogen-activating protein (FAP) for the in vivo fluorescence and photoacoustic imaging of cancer cells. We found that the TaOx shell can provide a natural cover for the enclosed fluorogen/FAP complexes, protecting them from photobleaching and common biodegradation. Moreover, we have developed a near-infrared excitable tetrafluorinated photoacoustic fluorogen for the specific and persistent photoacoustic imaging of tumors. We believe that this enclosing and delivery strategy of optical biomolecules will be an attractive alternative for bioimaging.