We consider the inverse problem of determining the shape of a general nonlinear term appearing in a semilinear hyperbolic equation on a Riemannian manifold with boundary (M, g) of dimension n = 2, 3. We prove results of unique recovery of the nonlinear term F (t, x, u), appearing in the equation ∂ 2 t u − Δgu + F (t, x, u) = 0 on (0, T ) × M with T > 0, from partial knowledge of the solutions u on the lateral boundary (0, T ) × ∂M . We obtain, what seems to be, the first result of determination of the expression F (t, x, u) on the boundary x ∈ ∂M for such a general class of nonlinear terms. With additional assumptions on the manifold and some extended measurements at t = 0 and t = T , we prove also the recovery of F inside the manifold x ∈ M .