The preparation of chemically resistant and flame retardant foams from polyfunctional aromatic carboxylic acid derivatives and organic polyisocyanates is outlined. It was found that polyimide foams of reproducible density above 1 lb./ft. and below 6 lbs./cu ft. can be obtained by employing in the reaction of least 2% by weight of siloxane-glycol copolymer as a surfactant which acts as a specific density control agent. Polyimide foams into which reinforcing fibers such as silicon dioxide and carbon fibers may be incorporated were also produced.