The 26-year-old, who spent time on loan at Plymouth Argyle last season and helped the Pilgrims gain promotion to the Championship, had been linked with a number of League One sides this summer including Charlton Athletic, Blackpool and Derby County.
The Beverley-born player reportedly rejected a proposed move to Charlton recently.
He has signed a two-year deal.
His arrival follows from the capture of Burnley loan defender Owen Dodgson.
Cosgrove has made two substitute appearances this season for Blues, both in the EFL Cup.
The bustling forward netted 12 times for Argyle last term.
The Yorkshireman started his career at Everton, before linking up with the Wigan Athletic academy.
He had subsequent spells at Barrow and North Ferriby United before departing for Carlisle United in 2017.
Cosgrove later moved north of the border to Aberdeen, where he enjoyed considerable success in scoring 47 goals in 103 appearances in his time at Pittodrie before returning to England and joining Birmingham.
In his time at Blues, he has also had loan stints at Shrewsbury Town and AFC Wimbledon.
Reds CEO Khaled El-Ahmad said: “Sam represents a different profile of striker to add to the forwards we currently have at the club and will add a different dimension to the attack.”