Koike et al. modelled human hepato-biliary-pancreatic (HBP) organogenesis from a culture of pluripotent stem cells. The HBP anlage (primordium) is first specified at the boundary between the foregut and the midgut. A 3D differentiation approach was used to specify gut spheroids with distinct regional identities comprising mesoderm and endoderm. Anteroposterior interactions between these spheroids recapitulated the foregut and midgut boundary in vitro and led to the development of structurally and functionally integrated HBP organoids.