You can use \middle|:
\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\begin{document}
$\mathrm{Aff}(M) := \left \{ \sum_{i=1}^k \lambda_i p_i \, \middle| \, p_i \in M, \lambda_i \in \mathbb{K}, \sum_{i=1}^k \lambda_i = 1\right \}$
\end{document}

Notice the two fine spaces I introduced (before and after the vertical bar) and the change from \text to \mathrm.
If instead of the \left\{...\right\} delimiters, some of the commands in the \big..., \Big... family is being used, then one can use the corresponding \bigm,\Bigm,... command:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
$\bigm\lvert\quad\Bigm\lvert\quad\biggm\lvert\quad\Biggm\lvert$
\end{document}

\text{}and nod\mathrm{}but\operatorname{}. – Martin Thoma Aug 24 '12 at 21:16$\bigm\lvert\quad\Bigm\lvert\quad\biggm\lvert\quad\Biggm\lvert$works with markups in Jupyter. – iperetta Sep 18 '20 at 22:20