Rashmi and Ragavan’s ability resolves before the spell that caused it to trigger, but not before you have to pay for the original spell. You won’t be able to use the Treasure token you create to pay for it.

Artwork
Loading artwork…
Rashmi and Ragavan
March of the Machine Commander · #8 · EN
Nonfoil—Foil—
Card rules
Whenever you cast your first spell during each of your turns, exile the top card of target opponent's library and create a Treasure token. Then you may cast the exiled card without paying its mana cost if it's a spell with mana value less than the number of artifacts you control. If you don't cast it this way, you may cast it this turn.
2/4
Mythic · Illustrated by Joshua Cairos
Format legality
Commander Legal
Duel Legal
Legacy Legal
Oathbreaker Legal
Vintage Legal
Alchemy Not Legal
Brawl Not Legal
Competitive Brawl Not Legal
Future Not Legal
Gladiator Not Legal
Historic Not Legal
Modern Not Legal
Old School Not Legal
Pauper Not Legal
Pauper Commander Not Legal
Penny Not Legal
Pioneer Not Legal
PreDH Not Legal
Premodern Not Legal
Standard Not Legal
Standard Brawl Not Legal
Timeless Not Legal
Tlr Not Legal
Rulings
Published rulings from the downloaded Scryfall catalog. Source card record · Rules and interactions
If you cast a spell without paying its mana cost, you can’t choose to cast it for any alternative costs. You can, however, pay any additional costs. If the spell has any mandatory additional costs, you must pay those.
Check the number of artifacts you control as the ability resolves, including the Treasure token you just created, to see if you can cast the exiled card without paying its mana cost.
Rashmi and Ragavan has to be on the battlefield at the moment you cast your first spell. Notably, on the turn you cast Rashmi and Ragavan, the ability won’t trigger for you that turn. If a spell causes Rashmi and Ragavan to leave the battlefield as an additional cost to cast it, the ability won’t trigger.
If you cast the spell without paying its mana cost, you do so during the resolution of the triggered ability. Timing restrictions of that spell based on card type are ignored. It will resolve before the spell that caused the ability to trigger.
If the spell has X in its mana cost, you must choose 0 as the value of X when casting it without paying its mana cost.
If you don’t cast the card at all, it remains exiled.
If you don’t cast it without paying its mana cost but rather cast it later in the turn, you must pay its costs, and you must follow all applicable timing rules. For example, if the card is a creature card, you can cast that card by paying its mana cost only during your main phase while the stack is empty.