The invention relates to a method for the controlled delivery of a drug as a function of bioavailable drug concentration, a sensor device for detecting bioavailable drug concentration, and a delivery device that controls delivery of the drug based on the real-time detection of bioavailable drug concentration.