Let $K/\mathbb{Q}$ be a quadratic imaginary field, and let $\chi$ be a Hecke character on $K$. Using Poisson summation, one can show that the theta function $$ \theta(z):=\sum_{I\subseteq \mathcal{O}_K} \chi(I) q^{|I|}, q = e^{2\pi i z} $$ satisfies a functional equation relating $\theta(z)$ to $\theta(-1/Nz)$, where $N$ is equal to the discriminant of $K$ times the norm of the conductor of $\chi$.

But from this equation, how can I deduce that $\theta$ is a modular form for $\Gamma_1(N)$ (or even for $\Gamma_0(N)$, with central character)?

What I have tried:

I thought it was easy, because the functional equation roughly says that $\theta$ is invariant under the action of the matrix $\begin{pmatrix} & 1 \\ -N & \end{pmatrix}$, and it is obvious that $\theta$ is invariant under the action of the matrix $\begin{pmatrix}1 & 1\\ & 1\end{pmatrix}$. Hence using a conjugation, we get the invariance by the matrix $\begin{pmatrix}1 & \\ N & 1\end{pmatrix}$.

Now the problem is solved, if one can show that the group $\Gamma_1(N)$ is generated by the two matrices $\begin{pmatrix}1 & 1\\ & 1\end{pmatrix}$ and $\begin{pmatrix}1 & \\ N & 1\end{pmatrix}$. But is this true? I tried to prove it with elementary methods, but failed ...

Or do I need other ingredients to prove the modularity?

EDIT:

According to the comment of Will Sawin, the above approach may be too naive.

So are there any reference (in classical language, i.e. no adelization or Weil representations) on how to prove this modularity? The character $\chi$ that I'm interested in is not necessarily of finite order: it could have some infinity type like $z \mapsto z^{-k}$.

possible, because Hecke did this. For a proof of modularity of (positive-definite, even-dimensional) theta series generally, see R. Gunning's book on modular forms. However, upon closer examination of his argument (which maybe goest back to Schoenberg, I forget), it is far better done on an adele group. Indeed, this is one of the things that persuaded me. (See also my book on Hilbert modular forms.) But/and, also, in Mumford's Tata lectures on thetas generators for congruence subgroups are given, even in larger symplectic groups. Again, not so illuminating, in my opinion. $\endgroup$ – paul garrett Jul 16 '17 at 19:06