N.Y. Criminal Procedure Law § 50.30
In any criminal proceeding, other than a grand jury proceeding, the court is a competent authority to confer immunity in accordance with the provisions of section 50.20, but only when expressly requested by the district attorney to do so.