Hi there, I have been having trouble sleeping at night. Wondering if I should look into ambien or some other type of medication. Is there anything that is safe and over the counter I can try? I have only had about 3-4 hours a sleep a night for the last 2

Peanut butter. try a little snack like peanut butter cracker with small glass of milk , can try diphenhydramine[benadryl ] 25 mg too , it lasts 12 hours so take it by 8pm . pray alot and don't have tv or lights going, get exersize in daytime, good sleep hygiene.
Seek Medcheck up. You will benefit from seeing your doctor to first find out the cause for your Insomnia. There are no good medicines available over the counter. Ambien (zolpidem) is good for some people but the choice of best medicine for good sleep depends on the underlying cause of your sleeplessness. One common cause is depression; this may require an antidepressant. But you should see a doctor to sort it all out.
Melatonin . Melatonin is a natural substance that is available over the counter. I would start with 3 mg 2 hours before bedtime ( do not drive or use sharp objects or tools after you take it). I would also refrain from taking any products with caffeine after 12 noon and use of TV or media one hour before your bedtime .