However, City coasted through the second half as efforts from Gabriel Jesus and Fernandinho took the club to within three points and two goals of breaking Chelsea's records for most points and most goals scored in the Premier League.
As for West Ham, David Moyes's team remain three points clear of the relegation zone, but his side's goal difference could now come into play during the final two weeks of the season.
City dominated the opening stages of the game but their opening goal came in fortuitous circumstances with Sane's long-range effort taking a deflection off Patrice Evra, with the ball deceiving Adrian and ending up in the far corner.
West Ham almost delivered an instant reply with Manuel Lanzini's cross-cum-shot being parried away by Ederson, but the Hammers looked there for the taking at the back and Raheem Sterling should have scored from 12 yards rather than dragging an effort well wide.
City's second goal arrived just before the half-hour mark when Kevin De Bruyne received the ball on the right-hand side of the penalty area and after Adrian had made a small connection with the delivery, Rice could only divert the ball into his own net.
Sane should have done better with a one-on-one opening soon afterwards and West Ham took encouragement from that moment, only to be denied a goal for a debatable foul by Marko Arnautovic on Ederson and the assistant wrongly claiming that a foul on Edimilson Fernandes had taken place marginally outside the box.
However, from the resulting set piece, Cresswell stepped up to curl a shot from 20 yards just inside Ederson's near post, and it lifted West Ham after being outplayed for a large period of the opening 45 minutes.
City ended the first half strongly, though, with De Bruyne and Sterling both failing to take advantage of being given time inside the area, and it did not take long after the restart for Pep Guardiola's side to put the match out of West Ham's reach.
Sterling was getting more and more time on the ball down the right flank and after picking out the run of Jesus, the Brazilian breezed past Pablo Zabaleta before finding the bottom corner from close range.
Just before the hour mark, Sterling was denied a penalty - despite being taken out by Cresswell on the byline - but City remained relentless as De Bruyne and Ilkay Gundogan both failed to hit the target.
Adrian then blocked from Sterling to atone for his poor clearance seconds earlier but an almost inevitable fourth arrived in the 64th minute when the winger picked out the run of Fernandinho who swept the ball into the bottom corner from 10 yards.
Guardiola took the opportunity to introduce Yaya Toure for another cameo appearance before potentially leaving the club at the end of the season, while young forward Lukas Nmecha was handed his Premier League debut.
The closing stages of the game passed by without incident as both clubs accepted that the game was already over as a contest and City now move on to their final three games still holding an opportunity to achieve over 100 points for the campaign.
WEST HAM UNITED (3-5-1-1): Adrian; Ogbonna, Rice, Cresswell; Zabaleta, Noble, Kouyate, Fernandes (Joao Mario 65'), Evra (Masuaku 66'); Lanzini (Hernandez 66'); Arnautovic
MANCHESTER CITY (4-5-1): Ederson; Walker (Danilo 61'), Laporte, Otamendi, Delph; Fernandinho, Gundogan (Toure 71'), De Bruyne, Sane, Sterling; Jesus (Nmecha 80') body check tags ::