Nick Kyrgios says he was struggling with illness and a shoulder issue when he followed through on a threat to retire from his Shanghai Masters first-round match against Steve Johnson.

Controversial figure Kyrgios was heard telling the umpire he would quit if he lost the first-set tie-break and he walked over to shake hands after Johnson fired down an ace on set point.

The Australian had already received a point penalty for an audible obscenity and was warned after his frustration at a line call got the better of him and he hit two balls out of court.

Kyrgios, who lost to Rafael Nadal in the China Open final at the weekend, was booed as he left the court but has apologised to fans via social media, citing a pair of ailments for his premature exit from the match.

"Guys, I want to apologise to the fans in Shanghai and those that watched around the world on TV today," he said in a statement posted on Twitter.

"I've been battling a stomach bug for the past 24 hours and I tried to be ready but I was really struggling on the court today which I think was pretty evident from the first point.

"My shoulder started to hurt in the practice today which didn't help either and once I lost the first set I was just not strong enough to continue because I've not eaten much the past 24 hours.

"I'm hoping to be okay for the doubles and will make a decision tomorrow morning, hopefully off of a good nights [sic] sleep which I didn't get last night.

"I'm gutted to be honest as I was keen to keep the good momentum that I built in Beijing going and finish the year strong. I'll do what I can to make sure I do."

Kyrgios was banned for eight tournament weeks and fined a total of $41,500 after he appeared to tank at the same tournament last year.

In the build-up to his opening singles match in Shanghai, the world number 21 wrote an article on the Players Voice website in which he declared the prospect of helping disadvantaged and underprivileged children has enabled him to find a "purpose" to play tennis at the highest level.