An optical sensor for detecting chemical, biochemical or biological substances includes a laser and a semiconductor chip. The sensor includes at least one photodetector and at least one high-contrast grating that are monolithically integrated in the semiconductor chip. The high-contrast grating is configured to optically couple radiation emitted by the laser into the photodetector. The coupling behavior of the high-contrast grating depends on the optical properties of external substances that are brought near to or in contact with the high-contrast grating.