Skip to content
zgrok ai

Expose a local AI model.

Ollama binds to 127.0.0.1 by default. The moment that changes, by setting OLLAMA_HOST=0.0.0.0 or forwarding a port on your router, there is no authentication in front of the model. Anyone who finds the address can use your hardware and read every prompt sent through it.

~/app · A model behind a token
$ zgrok ai 11434
✓ Online · llm--acme-shop.zgrok.io → Ollama
GET/v1/models2006 ms
POST/v1/chat/completions4010 ms
POST/v1/chat/completions20014.2 s
POST/v1/embeddings200310 ms
On this page

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.

1

A reachable address.

Something outside your machine has to be able to resolve a name and connect to it, without you opening a port on a router you may not even control.
2

Authentication in front of it.

Not a check the model performs after the request has already arrived, but one that happens before your hardware is asked to do anything at all. A wrong token should cost you nothing.
3

A request that is allowed to take minutes.

A cold model loading weights, or a non-streaming completion on a large context, can go a long time without producing a single byte. Anything in the path that treats silence as a fault will cut the request off exactly when the model is working hardest.

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.

AI Model

Which server it guessed

Names the server it guessed from the port and the loopback address it will forward to.
Base URL

What your client wants

Your public URL with /v1 already appended, which is the exact string an OpenAI-compatible client wants.
Token

The key to this tunnel

The bearer token for this tunnel.
Auth

The reminder

A one-line reminder that every request needs it.

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.

A shorter one is refused by the CLI before it dials, and refused again by the server if it somehow gets that far. Sixteen is a floor rather than a suggestion for a reason: a four-character token looks authenticated and is not.
$ zgrok ai
No port needed: 11434 is the fallback.

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.

  1. Install zgrok and sign in

    On macOS or Linux. The download page has the Windows command. zgrok login opens your browser to approve the machine, once.

    $ curl -fsSL https://zgrok.io/install.sh | sh
    $ zgrok login
  2. Have 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 serve first.

    $ ollama pull llama3.2
  3. Open 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 ai
  4. Call 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.

    bash
    curl 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.

Recorded on a local demo setup with a scripted model, so the answer and its timing are not a benchmark.
Text version
$ zgrok ai
 
Tunnel Status: online
Forwarding: https://llama--acme-shop.zgrok.io → http://localhost:11434
 
AI Model: Ollama → localhost:11434
Base URL: https://llama--acme-shop.zgrok.io/v1
Token: zg_ai_5c01daee9f4087c8af17db75
Auth: 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 .response
The 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.

  1. The token is checked at the edge.

    A request with no Authorization header, or with the wrong token, gets a 401 there, 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 the Bearer scheme are matched case-insensitively; the token itself has to match exactly.
  2. The token is then stripped.

    Once zgrok has validated it, the Authorization header 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 as X-Forwarded-Host.
  3. The Host header 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 the X-Forwarded-Host above.
ARRIVES AT THE EDGE
POST /v1/chat/completionsHost: llm--acme-shop.zgrok.ioAuthorization: Bearer zg_ai_3f9c1a7e5b2d8c4f6a1e9b07Content-Type: application/json
REACHES YOUR MODEL
POST /v1/chat/completionsHost: localhost:11434Added: X-Forwarded-Host: llm--acme-shop.zgrok.ioRemoved: Authorization: Bearer zg_ai_…Content-Type: application/json

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.

Waiting for the first byte45 s
Web tunnel504 at 10 s
Red mark: a 10 s first-byte window
AI tunnel200 · first token at 38 s
Waits for the model's first byte or the tunnel closing, whichever comes first

Which servers this covers

11434

Ollama

Listens on 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.
1234

LM Studio

The local server uses 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.
8000

vLLM

Serves its OpenAI-compatible API on 8000 unless you passed --port. Run zgrok ai 8000, or whichever port you chose.
8080

llama.cpp

The bundled server defaults to 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.

The server's authentication path does not ask what kind of tunnel it is opening, so there is no plan gate for an AI tunnel to fail. The bearer token, the edge check, the header rewriting and the absent first-byte deadline are all the same on the free plan.

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.

Next

Run your first tunnel.

Free to start. $9 for a URL that stays. You pay for features, never for traffic.