Using APEX-1 and APEX-2 observations, we have detected and studied the rotational lines of the HC 3 N molecule (cyanoacetylene) in the powerful outflow/hot molecular core G331.512-0.103. We identified thirty-one rotational lines at J levels between 24 and 39; seventeen of them in the ground vibrational state v=0 (9 lines corresponding to the main C isotopologue and 8 lines corresponding to the 13 C isotopologues), and fourteen in the lowest vibrationally excited state v 7 =1. Using LTE-based population diagrams for the beam-diluted v=0 transitions, we determined T exc =85±4 K and N (HC 3 N)=(6.9±0.8)×10 14 cm −2 , while for the beam-diluted v 7 =1 transitions we obtained T exc =89±10 K and N (HC 3 N)=2±1×10 15 cm −2 . Non-LTE calculations using H 2 collision rates indicate that the HC 3 N emission is in good agreement with LTE-based results. From the non-LTE method we estimated T kin ≃90 K, n(H 2 )≃2×10 7 cm −3 for a central core of 6 arcsec in size. A vibrational temperature in the range from 130 K to 145 K was also determined, values which are very likely lower limits. Our results suggest that rotational transitions are thermalized, while IR radiative pumping processes are probably more efficient than collisions in exciting the molecule to the vibrationally excited state v 7 =1. Abundance ratios derived under LTE conditions for the 13 C isotopologues suggest that the main formation pathway of HC 3 N is C 2 H 2 + CN → HC 3 N + H.