Caveat: It is different for everyone.
Inspiration for me is derived from emotion and external input. Depending on style it may be a matter of getting into the right head state first before laying down a track.
If you write dance music it is not ideal for you to be mopey.
If you write sad music it doesn't help to be happy.
If you just heard the best track you have ever heard and you seek to emulate that your emotional state will probably allow it.
External input might be learning a new way of doing things or a new style. It could be a new instrument or a new chord. It could be playing a few bars and getting an idea... These things can cause our emotional state to line up and create a space for intuition and creativity to work.
Some of the best technical works I have created never got released cause they did nothing for me.. and at the end of the day, I am seeking to be inspired.
thats my 2 cents.