Sam Allardyce's first match in charge of the Hammers, who are favourites for promotion back to the top flight, looked to be heading towards a goalless draw.
But Miller crashed home a dramatic winner on his Cardiff debut as West Ham were given a stark reminder that the Championship may not be the cakewalk the bookmakers are predicting.
Their midfield pairing of Kevin Nolan and Scott Parker would not look out of place in most Premier League teams yet the illustrious duo could not break down a well-organised Cardiff side with a new manager of their own in Malky Mackay.
Parker should have put the home side ahead after 10 minutes when he found himself bearing down on goal but his touch let him down and Anthony Gerrard was able to make the challenge.
Frederic Piquionne - preferred in attack to Carlton Cole - also had an early opportunity but his shot was blocked by the legs of Cardiff goalkeeper David Marshall, while Nolan headed wide and Freddie Sears blazed over.
Allardyce has also managed to keep hold of Robert Green, another member of Fabio Capello's squad, for the time being and the goalkeeper was called into action to pull off a smart save from Don Cowie's header.
Green also had to tip Peter Whittingham's free-kick round the post as Cardiff finished the first half strongly while West Ham's early promise faded.
After the break Matt Taylor, another of Allardyce's summer recruits, tried to breathe some life into his new side.
First the ex-Bolton midfielder cut inside and drove in a low shot which Marshall palmed away, then his strong run and cross was turned onto a post by Piquionne.
Defender James Tomkins thought he had broken the deadlock but his header was blocked on the line by Whittingham, while Marshall saved from Pablo Barrera a minute from time.
And as the clock ticked into stoppage time Miller, who had hardly had a sniff all game, collected a pull-back from substitute Rudy Gestede and lashed the ball past Green, who got a hand to the ball but could not keep it out.