Optimal generation of entangled states is of critical significance for robust quantum information processing. An effective scheme is presented for speeding up the generation of an entangled state between a superconducting qubit and microwave photons via counterdiabatic driving. At a magic bias point, the first three levels of a charge-phase quantum circuit constitute an effective qutrit. An entangled state based on adiabatic population transfer is first achieved. By the technique of shortcuts to adiabaticity, a counterdiabatic driving is applied to the qutrit, which then accelerates the entanglement generation significantly. Moreover, with the accessible decoherence rates, the rapid operations in a shortcut way are highly robust when compared with adiabatic manipulations. The scheme could offer a promising approach toward optimal preparation of entangled states with superconducting artificial atoms in circuit quantum electrodynamics, experimentally.