When to apply H4 for my spouse

I am not currently in the USA and I am waiting for my company to file H1B for me.

Meanwhile, I am wondering when I should apply H4 for my spouse.

Should I ask my company to apply H4 for my spouse while filing I-129?

Or wait until my H1B is approved and take I-797 to american institute in my country to apply H4 visa for my spouse while I apply for my USA entry visa?

You cannot apply for H-4 visa without H1B approval. The typical process is that your employer applies for H1B approval and after you get the approval notice ( I-797 form), you will work with employer to get relevant documents for H1B visa stamping. When you apply for H1B visa at consulate, you can apply H4 visa stamping for your spouse as well by filling in additional DS-160 form for the spouse. Alternatively, H4 holder can apply for H4 visa at consular on their own at later time by carrying relevant documents corresponding to H1B holder as proof and other documents supporting the relationship. H-4 visa holder will not get anything like I797 , but will need to carry the spouses H1B approval notice and other documents as needed.