The left-handed South Australian went for an x-ray on an injured finger which was struck by a ball from by David Wigley, who finished with five for 77.
At that stage he was on 94, but decided to carry on to reach his century - from 136 balls with
18 fours and one six - before retiring hurt.
After the x-ray revealed no break Cosgrove did come back into bat at the end of Glamorgan's innings but did not face a ball as they were bowled out for 308. In reply Northamptonshire were nought without loss at the close of play after their openers negotiated one over.
Monty Panesar, who will want to be at the ground for the first Ashes Test in just over three weeks, did little to press his cause, finishing with figures of one for 81 from 28 overs.
Cosgrove, keen to make an impression in his last championship appearance before he is replaced as overseas player by Herschelle Gibbs, dominated the first half of the opening day's play, putting on a second successive century partnership with Michael Powell, who contributed a patient 88 in five hours 18 minutes in the middle.
After winning the toss Glamorgan found themselves 29 for two inside 10 overs thanks to Wigley.
Out-of-form Gareth Rees edged a wide one behind before Ben Wright was bowled via an inside edge two balls later.
Some typical hard-hitting gave Cosgrove his fifth score of more than 50 in seven innings. His half-century came off 73 balls.
A key moment came when David Murphy, deputising for Niall O'Brien, missed a relatively easy stumping off Panesar when Cosgrove was on 84.
Despite being in pain after being hit by Wigley, Cosgrove was determined to reach his century, which he did via an inside edge for four off the same bowler.
His retirement brought captain Jamie Dalrymple to the middle, but there was a rare failure for the batsman who was averaging 88.5 going into the game. He went for one, caught behind off Wigley.
Powell, who reached a patient 50 from 153 balls, and Mark Wallace added 58 before the wicketkeeper was bowled via a bottom edge off Panesar.
There was a whirlwind 43 from 40 balls by Robert Croft but Glamorgan lost their last four wickets for just two runs.