This example give you how to solve :
ClearAll["`*"]
f[x_, y_] := Cos[x^2 - 3 y] + Sin[x^2 + y^2];
GRADf = Grad[f[x, y], {x, y}](*A Gradient*)
(*{2 x Cos[x^2 + y^2] - 2 x Sin[x^2 - 3 y], 2 y Cos[x^2 + y^2] + 3 Sin[x^2 - 3 y]} *)
f = Integrate[GRADf[[1]], x] // FullSimplify(* Yours function f *)
(* Cos[x^2 - 3 y] + Sin[x^2 + y^2] *)
Check:
Integrate[GRADf[[1]], x] - Integrate[GRADf[[2]], y] // FullSimplify(*OK*)
(* 0 *)
Integrating constant's in this case is zero !