We present a broadband modeling of the afterglow of GRB 021004. The optical transient of this burst was detected very early and densely sampled in several bands. Its light curve shows significant deviations from a simple power law. We use the data from the X-ray to the I band gathered in the first month of observations and examine three models. Two involve variations in the energy of the shock. The first (energy injection) allows only increases to the shock energy, while the second (patchy shell) allows the energy to increase or decrease. In the final model (clumpy medium), the energy of the shock is constant while the density varies. While all three models reproduce well the optical bands, the variable density model can best account for the X-ray data, and the energy-injection model has the poorest fit. None of the models can account for the modest color variations observed during the first few days of the burst.