Expose your local LM Studio as a public OpenAI-compatible API endpoint using Cloudflare Tunnel. No signup required!
Share your local LLM with coworkers, use it in VS Code, or connect from anywhere.
- No signup required - Uses free Cloudflare quick tunnels
- OpenAI-compatible API - Works with any OpenAI SDK client
- Streaming support - Real-time token streaming
- Built-in tester - Automatically test all endpoints
- Logging - See all requests in real-time
git clone https://github.com/cronos3k/LM-Studio-API-Proxy.git
cd LM-Studio-API-Proxy
pip install -r requirements.txtWindows:
curl -L -o cloudflared.exe https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-windows-amd64.exeMac:
brew install cloudflaredLinux:
curl -L -o cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared- Open LM Studio
- Load a model
- Start local server (default:
localhost:1234)
python lmstudio_proxy.pyYou'll see:
============================================================
LM Studio API Proxy (Cloudflare Tunnel)
============================================================
LM Studio: http://localhost:1234
Status: [OK] Model: mistralai/codestral-22b-v0.1
============================================================
Local API: http://localhost:8000/v1
Starting Cloudflare tunnel...
============================================================
PUBLIC URL: https://random-words.trycloudflare.com/v1
============================================================
python test_endpoint.py https://your-url.trycloudflare.com/v1from openai import OpenAI
client = OpenAI(
base_url="https://your-url.trycloudflare.com/v1",
api_key="not-needed"
)
response = client.chat.completions.create(
model="mistralai/codestral-22b-v0.1",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)curl https://your-url.trycloudflare.com/v1/chat/completions \
-H "Content-Type: application/json" \
-d "{\"model\": \"mistralai/codestral-22b-v0.1\", \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]}"Edit ~/.continue/config.json:
{
"models": [{
"title": "LM Studio Remote",
"provider": "openai",
"model": "mistralai/codestral-22b-v0.1",
"apiBase": "https://your-url.trycloudflare.com/v1",
"apiKey": "not-needed"
}]
}python lmstudio_proxy.py [OPTIONS]| Option | Description | Default |
|---|---|---|
--host |
LM Studio host | localhost |
--port |
LM Studio port | 1234 |
--proxy-port |
Local proxy port | 8000 |
# Default (localhost:1234)
python lmstudio_proxy.py
# Custom LM Studio address
python lmstudio_proxy.py --host 192.168.1.100
# Custom ports
python lmstudio_proxy.py --port 8080 --proxy-port 9000| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/v1/models |
GET | List available models |
/v1/chat/completions |
POST | Chat completions (streaming supported) |
/v1/completions |
POST | Text completions (streaming supported) |
/v1/embeddings |
POST | Generate embeddings |
Run the built-in endpoint tester:
# Test remote URL
python test_endpoint.py https://your-url.trycloudflare.com/v1
# Test local
python test_endpoint.py http://localhost:8000/v1Output:
============================================================
LM Studio API Proxy - Endpoint Tester
============================================================
Target: https://your-url.trycloudflare.com/v1
[1/6] Testing health endpoint...
[OK] Health check passed
[2/6] Testing models endpoint...
[OK] Models endpoint works - Found 19 models
[3/6] Testing chat completions...
[OK] Chat completions works (3.6s, 25 tokens)
[4/6] Testing streaming...
[OK] Streaming works (4.1s, 31 chunks)
[5/6] Testing OpenAI SDK...
[OK] OpenAI SDK works (3.4s)
[6/6] Testing completions endpoint...
[OK] Completions endpoint works
============================================================
All tests passed! (6/6)
============================================================
| File | Description |
|---|---|
lmstudio_proxy.py |
Main proxy server (Cloudflare tunnel) |
test_endpoint.py |
Endpoint tester |
requirements.txt |
Python dependencies |
cloudflared.exe |
Cloudflare tunnel binary (download separately) |
[Your Coworker / VS Code / Any Client]
|
| (internet)
v
[Cloudflare Tunnel] -----> [This Proxy] -----> [LM Studio]
(trycloudflare.com) port 8000 port 1234
- LM Studio runs locally with your model
- This proxy creates an OpenAI-compatible API
- Cloudflare tunnel exposes it publicly (no port forwarding needed)
- Anyone with the URL can use your model
- Make sure LM Studio is running
- Check that local server is started
- Verify port (default: 1234)
- Download cloudflared binary (see Quick Start)
- Place it in the same folder as the script
- Cloudflare generates a new random URL each time
- Share the new URL with your users
- URLs are random and hard to guess
- Anyone with the URL can use your model
- Only share with trusted people
- Stop the script when not in use
MIT