Ptychography, a scanning coherent diffraction imaging method, can produce a high-resolution reconstruction of a sample and, at the same time, of the illuminating beam. The emergence of vacuum ultraviolet and X-ray free electron lasers (FELs) has brought sources with unprecedented characteristics that enable X-ray ptychography with highly intense and ultra-fast short-wavelength pulses. However, the shot-to-shot pulse fluctuations typical for FEL pulses and particularly the partial spatial coherence of self-amplified spontaneous emission (SASE) FELs lead to numerical complexities in the ptychographic algorithms and ultimately restrict the application of ptychography at FELs. We present a general adaptive forward model for ptychography based on automatic differentiation, which is able to perform reconstructions even under these conditions. We applied this model to the first ptychography experiment at FLASH, the Free electron LASer in Hamburg, and obtained a high-resolution reconstruction of the sample as well as the complex wavefronts of individual FLASH pulses together with their coherence properties. This is not possible with more common ptychography algorithms.