"We have so far carried out 13 dead civilians and over 30 who were injured. The death toll is higher and we are busy collecting casualties," Ali Muse, an ambulance service official, said.
In another statement, Muse said: "Several children are among the dead."
He described the shelling as the "worst in months.
The president, the prime minister, the parliament speaker, the country's chief of staff, the police chief and other senior government officials were attending the ceremony during the attack.
Somali government officials confirmed the shelling but declined to give details.
The two remote-controlled roadside bombs targeted an AU convoy, but killed four civilians and two police officers, police and residents said.
"The first bomb nearly hit the AU's last car," Nur Salad, a Somali police officer, told Reuters news agency.
"Some policemen and residents ran to the scene, and then the next bomb exploded killing these people."
Somalia's fragile government controls just a few blocks in the capital while al-Shabab fighters, who have vowed to topple the UN-backed administration, and other armed groups control much of southern and central Somalia.
The government has said for several months that it plans to launch a major offensive against al-Shabab, which has professed loyalty to al-Qaeda.
Thousands of people have been killed and hundreds of thousands have fled the fighting in Mogadishu.