We demonstrate the on-chip generation and detection of terahertz radiation in coupled cavity systems using a single semiconductor heterostructure. Multiple sections of a terahertz quantum cascade laser structure in a double-metal waveguide are optically coupled and operate either as a laser or an integrated emission monitor. A detailed analysis of the photon-assisted carrier transport in the active region below threshold reveals the detection mechanism for photons emitted by the very same structure above threshold. Configurations with a single laser cavity and two coupled laser cavities are studied. It is shown that the integrated detector can be used for spatial sensing of the light intensity within a coupled cavity.