What you actually want
Three things have to be true at the same time, and the obvious fixes give you at most two of them.
A reachable address.
Authentication in front of it.
A request that is allowed to take minutes.
Changing OLLAMA_HOST gives you the first and drops the second. Putting a reverse proxy in front of that gives you the first two, and whether you keep the third depends entirely on how its read timeout is configured. zgrok ai is the three of them together.
One command
Leave your model server exactly as it is, listening on loopback, and point zgrok at its port. With no port named on the command line and none set as default_port in your config, zgrok ai falls back to 11434, which is Ollama's default.
$ zgrok ai # Ollama, port 11434 by default$ zgrok ai 1234 # LM Studio$ zgrok ai 8000 # vLLM, or any other OpenAI-compatible server
The CLI prints the usual tunnel banner and then four more labelled lines.
Which server it guessed
What your client wants
/v1 already appended, which is the exact string an OpenAI-compatible client wants.The key to this tunnel
The reminder
If you do not supply a token, zgrok generates one for you and prints a note under it saying it was generated for this session and will not be shown again. Supply your own with --token, or pin one as ai_token in ~/.zgrok/config.yaml, and that note does not appear, because there is nothing new to save.
A token you supply has to be at least 16 characters.
From nothing to a first answer
The whole path with Ollama. With another server only the second step changes, and the port in the third.
Install zgrok and sign in
On macOS or Linux. The download page has the Windows command.
zgrok loginopens your browser to approve the machine, once.$ curl -fsSL https://zgrok.io/install.sh | sh$ zgrok loginHave a model ready
If Ollama is already running, as its desktop app does for you, pulling a model is all there is to do. Otherwise start it with
ollama servefirst.$ ollama pull llama3.2Open the tunnel
Leave this running, and copy the Base URL and the Token it prints. The tunnel lasts as long as the command does.
$ zgrok aiCall it from somewhere else
Start with the list of models, which answers without loading one. With the token it answers; without it, the same request gets a
401.bashcurl https://llama--acme-shop.zgrok.io/v1/models \ -H "Authorization: Bearer YOUR_TOKEN"
Here are the last two steps in one recording, with Ollama's own API answering a prompt. The address is a chosen name, which is a Pro feature, and the token was set in the config beforehand.
Text version
$ zgrok aiTunnel Status: onlineForwarding: https://llama--acme-shop.zgrok.io → http://localhost:11434AI Model: Ollama → localhost:11434Base URL: https://llama--acme-shop.zgrok.io/v1Token: zg_ai_5c01daee9f4087c8af17db75Auth: Bearer token required on every request[00:53:39] POST /api/generate 200 2633ms$ curl -sN https://llama--acme-shop.zgrok.io/api/generate \-H "Authorization: Bearer zg_ai_5c01daee9f4087c8af17db75" \-d '{"model":"llama3.2","prompt":"Why is the sky blue?"}' | jq -j .responseThe sky looks blue because air molecules scatter short, blue wavelengths of sunlight much more strongly than long, red ones, so blue light reaches your eyes from every part of the sky.
What the tunnel does to the request
This is behaviour, not intent. All of it lives in the tunnel server's HTTP listener and runs on every request to an AI tunnel.
The token is checked at the edge.
A request with noAuthorizationheader, or with the wrong token, gets a401there, before any QUIC stream to your machine is opened. Your GPU is never woken up by a wrong guess. The comparison is constant-time. The header name and theBearerscheme are matched case-insensitively; the token itself has to match exactly.The token is then stripped.
Once zgrok has validated it, theAuthorizationheader is removed from the request head before it is forwarded. The model never sees it, so it cannot be written into a local log, and it cannot collide with a key your model server expects for its own reasons. The public hostname the request arrived on is preserved separately asX-Forwarded-Host.The
Hostheader is rewritten to loopback.The request that reaches your machine is addressed to the local port the tunnel is forwarding to, not to the public hostname it arrived on. A model server that accepts only requests addressed to loopback therefore sees what it expects, and you do not have to widen that setting to put a tunnel in front of it. The public hostname is not lost: it is theX-Forwarded-Hostabove.
Why slow models do not get cut off
A normal web tunnel gives whatever is behind it a fixed window to produce a first byte and returns a gateway error if it misses. That is the right rule for a web app and the wrong rule for a model, where the gap before the first token is the work, not a symptom.
An AI tunnel has no first-byte deadline. The first read races the tunnel's own liveness instead of a clock: zgrok waits for either your model's first byte or the tunnel connection closing, whichever happens first. A completion that takes minutes still arrives. A tunnel that has genuinely died still fails immediately, because the thing being waited on is the connection itself rather than a countdown that has to expire. Silence from your model is never treated as a fault on its own.
Both response shapes work. Tokens streamed as they are produced arrive as they are produced, and a single non-streaming response arrives when your model has finished composing it.
Which servers this covers
Ollama
11434, which is why that is the fallback described above. The Host rewrite above applies to it exactly as it does to every other AI tunnel, so you can leave OLLAMA_HOST where it is. See the Ollama page for the short version.LM Studio
1234 by default, though it reuses the last port you ran it on, so check the app if you have ever changed it. Then run zgrok ai 1234, or whichever port it is listening on.vLLM
8000 unless you passed --port. Run zgrok ai 8000, or whichever port you chose.llama.cpp
8080. Same shape: zgrok ai 8080.Anything else that speaks an OpenAI-compatible HTTP API works the same way. The tunnel reads and rewrites the head of a request, in the ways above, and the head of the response coming back. Everything after a head is copied through unchanged, so whatever your server puts in a body is not something the tunnel has to understand. The banner labels ports it does not recognise as a local model and is otherwise identical.
What it costs
zgrok ai is not a PRO feature.
Two things about the free plan are worth knowing before you build on it. You can run two tunnels at once; PRO raises that to ten. And the address the server assigns you is rewritten each session: stop the tunnel, start it again, and you get a different tunnel name in front of your project. A tunnel left running gets a new one every 24 hours too. That is fine for a session you are sitting in front of, and wrong for a value you want to paste into a config file once and forget. A name you introduce with --subdomain is a PRO feature and stays yours, including across a later downgrade. Naming an address the server had already handed you is a different thing: it was never a name you chose, so it lapses and rotates like any other assigned one.
The full comparison is on the pricing page.