4. The minimum value of the function $f(x)=|x+1|+|a x+1|$ is $3 / 2$, then the number of real values of $a$ is ( ).
A. 1
B. 2
C. 3
D. 4
4. B

The graph of the function $f(x)=|x+1|+|a x+1|$ is a broken line, and $f(x)$ reaches its minimum value at the breakpoints, i.e., when $x+1=0$ or $a x+1=0$, the function $f(x)$ may reach its minimum value $\frac{3}{2}$.

When $a=0$, $f(x)=|x+1|+1 \geq 1$, and when $x=-1$, the equality holds, so $a=0$ is not a solution to the problem.

When $a \neq 0$, (1) If $x=-1$, then $|-a+1|=\frac{3}{2}$, i.e., $a=-\frac{1}{2}$ or $\frac{5}{2}$. In this case,
$$
f(x)=|x+1|+\left|-\frac{1}{2} x+1\right| \geqslant \frac{3}{2} \text {, or } f(x)=|x+1|+\left|\frac{5}{2} x+1\right| \geqslant \frac{3}{2},
$$
so $a=-\frac{1}{2}$ is a solution to the problem.
(2) If $x=-\frac{1}{a}$, then $\left|-\frac{1}{a}+1\right|=\frac{3}{2}$, i.e., $a=-2$ or $\frac{2}{5}$. In this case, $f(x)=|x+1|+|-2 x+1| \geqslant \frac{3}{2}$, or $f(x)=|x+1|+\left|\frac{2}{5} x+1\right| \geqslant \frac{3}{2}$, so $a=-2$ is a solution to the problem.