  This is the first paper in a series to study vertex algebra-like objects
arising from infinite-dimensional quantum groups (quantum affine algebras and
Yangians). In this paper we lay the foundation for this study. For any vector
space $W$, we study what we call quasi compatible subsets of $\Hom (W,W((x)))$
and we prove that any maximal quasi compatible subspace has a natural nonlocal
(namely noncommutative) vertex algebra structure with $W$ as a natural faithful
quasi module in a certain sense and that any quasi compatible subset generates
a nonlocal vertex algebra with $W$ as a quasi module. In particular, taking $W$
to be a highest weight module for a quantum affine algebra we obtain a nonlocal
vertex algebra with $W$ as a quasi module. We also formulate and study a notion
of quantum vertex algebra and we give general constructions of nonlocal vertex
algebras, quantum vertex algebras and their modules.
