  Given a finite-dimensional reductive Lie algebra $\mathfrak{g}$ equipped with
a nondegenerate, invariant, symmetric bilinear form $B$, let
$V^k(\mathfrak{g},B)$ denote the universal affine vertex algebra associated to
$\mathfrak{g}$ and $B$ at level $k$. Let $\mathcal{A}^k$ be a vertex
(super)algebra admitting a homomorphism $V^k(\mathfrak{g},B)\rightarrow
\mathcal{A}^k$. Under some technical conditions on $\mathcal{A}^k$, we
characterize the coset $\text{Com}(V^k(\mathfrak{g},B),\mathcal{A}^k)$ for
generic values of $k$. We establish the strong finite generation of this coset
in full generality in the following cases: $\mathcal{A}^k =
V^k(\mathfrak{g}',B')$, $\mathcal{A}^k = V^{k-l}(\mathfrak{g}',B') \otimes
\mathcal{F}$, and $\mathcal{A}^k = V^{k-l}(\mathfrak{g}',B') \otimes
V^{l}(\mathfrak{g}",B")$. Here $\mathfrak{g}'$ and $\mathfrak{g}"$ are
finite-dimensional Lie (super)algebras containing $\mathfrak{g}$, equipped with
nondegenerate, invariant, (super)symmetric bilinear forms $B'$ and $B"$ which
extend $B$, $l \in \mathbb{C}$ is fixed, and $\mathcal{F}$ is a free field
algebra admitting a homomorphism $V^l(\mathfrak{g},B) \rightarrow \mathcal{F}$.
Our approach is essentially constructive and leads to minimal strong finite
generating sets for many interesting examples. As an application, we give a new
proof of the rationality of the simple $N=2$ superconformal algebra with
$c=\frac{3k}{k+2}$ for all positive integers $k$.
