It is known that
$$
A_1(x_1, x_2) = \partial \varphi(x_1, x_2)/\partial x_1,
$$
$$
A_2(x_1, x_2) = \partial \varphi(x_1, x_2)/\partial x_2
$$
holds if and only if
$$
\partial A_1/\partial x_2 = \partial A_2/\partial x_1.
$$
What would be criteria on $A_i$ in a more general case: $$ A_i(x) = F_i(B_j(x), \partial B_k(x)/\partial x) $$ where $x = (x_1, ..., x_n)$ and number of functions $A_i$ is bigger than the number of functions $B_k$.