We present a new method for calculating and representing potential energy functions of molecular systems interacting with metals. The method, which is called embedded diatomics in molecules (EDIM), is based on the embedded atom method (EAM) for describing the energetics of metal-metal and metal-non-metal interactions and on the valence bond method for describing non-metal-non-metal covalent bonding. In the present paper, we give explicit equations for the EDIM Hamiltonian matrix elements for the cases of one-to-three monovalent atoms interacting with each other and with a bulk metal. The EDIM parameters are determined semiempirically for the case of hydrogen interacting with nickel. The method is used to calculate potential energy functions for H or H2 interacting with the three lowest index faces of Ni, and the results are discussed in detail.