# ngrok With Local LLMs: Test Authentication Before Sharing Ollama: runnable files

6 Python tests against a synthetic loopback HTTP server; no ngrok tunnel, Ollama, LM Studio or model inference run.

Download all files in this folder before running. The article is at https://oneruby.dev/how-i-use-ngrok-with-local-llms-and-why-you-should-too/.

## Reproduce

Tested with Python 3.11.5 on arm64 macOS. Standard library only.

```sh
python3 -B -m unittest -v test_example.py
```

The tests bind an ephemeral 127.0.0.1 port and close the server afterward. No ngrok or model installation is needed. For your separately configured Basic-auth tunnel, set LLM_BASE_URL (HTTPS origin without /v1), LLM_MODEL, EDGE_USER and EDGE_PASSWORD privately, then run python3 example.py. This opens two real requests to the supplied endpoint. The direct script is not part of the local fixture test, and no real tunnel was opened for this article. request_chat accepts a separately prepared Bearer header for a backend requiring it; do not combine conflicting Authorization schemes.

## Files

- [example.py](example.py)
- [requirements.txt](requirements.txt)
- [test_example.py](test_example.py)

## Boundaries

- Loopback HTTP fixture verifies client behavior, not live ngrok policy enforcement or a model server.
- Traffic Policy and real endpoint setup are documentation-based and unexecuted.
- Only a small non-streaming chat response is checked; cold-start timeout, concurrency, rate limits and deployment exposure need independent measurement.
