Copolyesters of 3-hydroxypropionate (3HP) and 4-hydroxybutyrate (4HB), abbreviated as P(3HP-co-4HB), was synthesized by Escherichia coli harboring a synthetic pathway consisting of five heterologous genes including orfZ encoding 4-hydroxybutyrate-coenzyme A transferase from Clostridium kluyveri, pcs' encoding the ACS domain of tri-functional propionyl-CoA ligase (PCS) from Chloroflexus aurantiacus, dhaT and aldD encoding dehydratase and aldehyde dehydrogenase from Pseudomonas putida KT2442, and phaC1 encoding PHA synthase from Ralstonia eutropha. When grown on mixtures of 1,3-propanediol (PDO) and 1,4-butanediol (BDO), compositions of 4HB in microbial P(3HP-co-4HB) were controllable ranging from 12 mol% to 82 mol% depending on PDO/BDO ratios. Nuclear magnetic resonance (NMR) spectra clearly indicated the polymers were random copolymers of 3HP and 4HB. Their mechanical and thermal properties showed obvious changes depending on the monomer ratios. Morphologically, P(3HP-co-4HB) films only became fully transparent when monomer 4HB content was around 67 mol%. For the first time, P(3HP-co-4HB) with adjustable monomer ratios were produced and characterized.