You can’t. These are controlled substances and it is illegal to possess them without a prescription. No legitimate and safe outlet will sell them to you without a prescription.
Don’t try to buy online. The few online pharmacies that are legit are extremely expensive, and the rest are not safe or reliable. Many will take your money and you will never see the drugs, and the ones that send you drugs will send you pills you cannot trust.
Ambien and Valium are pennies a pill, even without insurance. Just ask your Doctor to refill your prescription, and ask for generic. A months supply of each is only a couple of dollars.