A method and apparatus to deliver a variable flow of oxygen to a patient. The apparatus may include a flow control valve, a pressure sensor to detect a patient's breathing pressure and ambient pressure, an oxygen flow analyzer to measure oxygen flow to the patient, and a processor to analyze the breathing pressure values, ambient pressure value, and oxygen flow rate values and to determine when a patient is inhaling. When the processor determines the patient is inhaling, the processor calculates an optimal oxygen flow rate to deliver to a patient, which may depend on a pre-selected flow rate and an oxygen backlog, and the processor sends a signal to the flow control valve to deliver the optimal oxygen flow rate to the patient.