Résumé : Context. The S-type asymptotic giant branch (AGB) star π1 Gru has a known companion at a separation of 2′ 7 (≈ 400 AU). Previous observations of the circumstellar envelope (CSE) show strong deviations from spherical symmetry. The envelope structure, including an equatorial torus and a fast bipolar outflow, is rarely seen in the AGB phase and is particularly unexpected in such a wide binary system. Therefore a second, closer companion has been suggested, but the evidence is not conclusive. Aims. The aim is to make a 3D model of the CSE and to constrain the density and temperature distribution using new spatially resolved observations of the CO rotational lines. Methods. We have observed the J = 3-2 line emission from 12CO and 13CO using the compact arrays of the Atacama Large Millimeter/submillimeter Array (ALMA). The new ALMA data, together with previously published 12CO J = 2-1 data from the Submillimeter Array (SMA), and the 12CO J = 5-4 and J = 9-8 lines observed with Herschel/Heterodyne Instrument for the Far-Infrared (HIFI), is modeled with the 3D non-LTE radiative transfer code SHAPEMOL. Results. The data analysis clearly confirms the torus-bipolar structure. The 3D model of the CSE that satisfactorily reproduces the data consists of three kinematic components: a radially expanding torus with velocity slowly increasing from 8 to 13 km s-1 along the equator plane; a radially expanding component at the center with a constant velocity of 14 km s-1; and a fast, bipolar outflow with velocity proportionally increasing from 14 km s-1 at the base up to 100 km s-1 at the tip, following a linear radial dependence. The results are used to estimate an average mass-loss rate during the creation of the torus of 7.7 × 10-7 M⊙ yr-1. The total mass and linear momentum of the fast outflow are estimated at 7.3 × 10-4 M⊙ and 9.6 × 1037 g cm s-1, respectively. The momentum of the outflow is in excess (by a factor of about 20) of what could be generated by radiation pressure alone, in agreement with recent findings for more evolved sources. The best-fit model also suggests a 12CO/13CO abundance ratio of 50. Possible shaping scenarios for the gas envelope are discussed.