Skip to content

Host gravity on your own GPU

Run gravity serve on a machine with a GPU and use it from other machines, for example from gravity click on your Mac. Keep the server private: only machines you choose should reach it.

On main, not in a release yet: 0.1.6 does not have the --host check in step 2 or gravity click --server in step 4. With 0.1.6, pass --api-key-file, --no-slots and --no-webui yourself.

The Linux x86_64 package runs on the CPU only. For an NVIDIA GPU, build from source.

1. Make an API key

openssl rand -hex 32 > ~/gravity-api-key
chmod 600 ~/gravity-api-key

--api-key-file reads the key from that file, so it does not show in the process list the way --api-key KEY does.

2. Start the server

gravity serve -m MODEL.gguf --mmproj MMPROJ.gguf -ngl 99 --host 0.0.0.0 --port 8080 --api-key-file ~/gravity-api-key

Every request must then carry Authorization: Bearer KEY.

gravity serve and gravity run check --host before they start llama-server. Any host other than this machine (127.x, localhost, ::1 or a .sock path) needs an API key: --api-key, --api-key-file or LLAMA_API_KEY. Without one, gravity exits with code 2 and prints:

gravity: --host 0.0.0.0 lets other machines reach this server; add --api-key KEY (or --api-key-file FILE, or LLAMA_API_KEY). Guide: https://astro-weights.dev/gravity/docs/how-to/host/

With a key, gravity turns /slots (it shows prompts) and the web UI off. --slots or --webui turns them back on. On this machine's own addresses nothing changes.

A source build has no gravity command and no such check. With build/bin/llama-server, pass --api-key-file, --no-slots and --no-webui yourself.

3. Reach it from other machines

Never open the port to the internet, and never put the server behind Tailscale Funnel: Funnel makes it public, and the API key is then the only lock on your GPU. Use one of these instead.

Tailscale Serve

Tailscale Serve shares a local port with your tailnet only. Start the server on this machine's address, then share the port:

gravity serve -m MODEL.gguf --mmproj MMPROJ.gguf -ngl 99 --host 127.0.0.1 --port 8080 --api-key-file ~/gravity-api-key
tailscale serve 8080

Other devices on your tailnet reach it at https://DEVICE.TAILNET.ts.net. Keep the API key on: everyone on the tailnet can reach the port.

Cloudflare Access

Put the server behind a Cloudflare Access self-hosted application, so only people your Access policy allows get through. gravity click sends only the API key header; it cannot sign in to Access or send an Access service token. For gravity click, use Tailscale Serve.

4. Use it from gravity click

On your Mac, with the key in GRAVITY_API_KEY (an environment variable does not show in the process list):

export GRAVITY_API_KEY=KEY
gravity click --server https://DEVICE.TAILNET.ts.net "the Save button"

The first time, gravity click asks in the terminal, because every run sends a screenshot of your screen to that server. Type yes. Click on screen has the details.