The starting point would be the SRD's entry for the Spells special ability, which any spellcasting (as opposed to (Sp) or (Su)s) monster has:

Quote Originally Posted by SRD
Spells
Sometimes a creature can cast arcane or divine spells just as a member of a spellcasting class can (and can activate magic items accordingly). Such creatures are subject to the same spellcasting rules that characters are, except as follows.

A spellcasting creature that lacks hands or arms can provide any somatic component a spell might require by moving its body. Such a creature also does need material components for its spells. The creature can cast the spell by either touching the required component (but not if the component is in another creature’s possession) or having the required component on its person. Sometimes spellcasting creatures utilize the Eschew Materials feat to avoid fussing with noncostly components.

A spellcasting creature is not actually a member of a class unless its entry says so, and it does not gain any class abilities. A creature with access to cleric spells must prepare them in the normal manner and receives domain spells if noted, but it does not receive domain granted powers unless it has at least one level in the cleric class
So going off that, monsters have to come up with XP where it's required too.

That said, Solars have Wish at will as a spell-like ability, and ...

Quote Originally Posted by SRD
A spell-like ability has no verbal, somatic, or material component, nor does it require a focus or have an XP cost.
Wish includes making nonmagical items of 25,000gp each, so it can self-generate expensive stuff. As for XP, Wish allows it to duplicate the Distilled Joy spell. It takes a while, but generates 2 XP for item crafting purposes. And Wish can accordingly be used to get around the material or XP components of any spell, since it duplicates the effects and it's (Sp).