Quote Originally Posted by Schadenfreuda View Post
What rules, if any, govern how monsters with innate spellcasting such as dragons or Solars use spells with XP components? If a Solar casts Miracle, what resource is expended? Do they have some daily or weekly XP budget, or do they take negative levels after so many uses or something to that effect?
This isn't addressed anywhere for creatures in general as far as I know, but it is addressed for two specific types: deities and dragons.
Quote Originally Posted by D&DG p.29
As characters of around 60th level, deities can freely pay even large XP costs. Consider that a deity has a safe cushion of around 30,000XP it can use every week for creating magic items and casting spells with spells with experience point costs.
Quote Originally Posted by Drac p.24
A dragon typically has a cushion of 100 to 600 XP times its spellcaster level. It can use these XP in spellcasting without risking the loss of a level.
Obviously deities are a special case, so presumably the dragon figure is a better guide to RAI for other creatures. Having said that, true dragons often get better stuff than other monsters (most types get triple standard treasure for example) so this should maybe be considered the maximum rather than the average.

Quote Originally Posted by Schadenfreuda View Post
And for that matter, do NPCs in general have rules governing magic item creation and where they get the XP for that? I can't imagine every enchanter out there just happens to also be a mercenary adventurer going out and raiding dungeons all the time to keep up their business; and if they actually all are, I shudder to think of the ecological consequences for the monster species they must hunt.
You do get XP for activities other than fighting monsters, but in most cases it's much slower. Exactly how this works has never been spelled out as far as I know. Tbh, how the world works in the background is always a bit of a handwave, from the fact that an ecosystem couldn't support nearly as many giant monsters as a typical D&D world seems to have, to the completely nonsensical demographics rules in the DMG. Don't examine this too closely, as they say on TV Tropes.