The city attorney of a city of the first class shall be the legal advisor of the city council and other city officers. The city attorney shall commence, prosecute, and defend all suits and actions necessary to be commenced, prosecuted, or defended on behalf of the city, or that may be ordered by the city council. He or she shall attend meetings of the city council and give them his or her opinion upon any matters submitted to him or her, either orally or in writing as may be required. The mayor and city council shall have the right to pay the city attorney additional compensation for legal services performed by him or her for the city or to employ additional legal assistance and to pay for such legal assistance out of the funds of the city. Whenever the mayor and city council have by ordinance so authorized, the board of public works shall have the right to pay the city attorney additional compensation for legal services performed by him or her for it or to employ additional legal assistance other than the city attorney and pay such legal assistance out of funds disbursed under the orders of the board of public works.