Three polyimides containing a nonlinear optical (NLO) chromophore were prepared through a new synthetic pathway. Coupling of dihydroxy and diimide compounds yielded the polyimide. Due to the mild conditions of polymerization, a chemically labile hemicyanine dye could be incorporated in the polyimide backbone successfully. The molecular weights of the polyimides obtained ranged from 8200 to 14 400, and the glass transitions occurred between 135 degrees C and 198 degrees C. The second-order NLO properties were characterized by using the second harmonic generation (SHG) technique. The second-order NLO coefficients (chi((2))) of the polyimides were 82 pm V-1 and 122 pm V-1 with reference to quartz crystal, and the nonlinearity of those polymers was stable at 100 degrees C without large loss.